<html>
<head><meta charset="utf-8"><title>stable subset of const generics · t-lang · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/index.html">t-lang</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html">stable subset of const generics</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="202925130"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/202925130" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#202925130">(Jul 05 2020 at 15:04)</a>:</h4>
<p>withoutboats (are they on zulip?) asked on the const generics tracking issue:</p>
<blockquote>
<p>Is there a subset of const generics that doesn't hit lazy normalization and doesn't have many bugs and papercuts, but which can express a good amount of useful code? I notice that std's impls of many traits for arrays seem to work just fine. Maybe there's a narrowing that would allow other crates to write the kind of impls we have in std for their own traits, even though they don't support all the fancier functionality?</p>
</blockquote>



<a name="202925187"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/202925187" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#202925187">(Jul 05 2020 at 15:06)</a>:</h4>
<p>Considering that this issue is corrently locked and should imo mostly be used for updates I wanted to move this to here for now (or a new issue on github <span aria-label="shrug" class="emoji emoji-1f937" role="img" title="shrug">:shrug:</span> don't really care).</p>



<a name="202925208"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/202925208" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#202925208">(Jul 05 2020 at 15:07)</a>:</h4>
<p>So I think that const generics with the following limitations should be fairly bug free and hopefully won't change much from now on:</p>



<a name="202925260"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/202925260" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#202925260">(Jul 05 2020 at 15:08)</a>:</h4>
<ul>
<li>only integer params, e.g. <code>const N: usize</code> and <code>const M: u8</code></li>
</ul>



<a name="202925263"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/202925263" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#202925263">(Jul 05 2020 at 15:08)</a>:</h4>
<ul>
<li>no where bounds</li>
</ul>



<a name="202925365"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/202925365" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#202925365">(Jul 05 2020 at 15:10)</a>:</h4>
<ul>
<li>only constants and params as generic arguments, i.e. we still forbid <code>[u8; size_of::&lt;T&gt;()]</code> and <code>[u8; N + 1]</code>.</li>
</ul>



<a name="202925433"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/202925433" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#202925433">(Jul 05 2020 at 15:12)</a>:</h4>
<p>Before this is usable we need to first land a replacement for <a href="https://github.com/rust-lang/rust/pull/71154">https://github.com/rust-lang/rust/pull/71154</a> though, so if that doesn't introduce a lot more bugs I believe it should be fairly save to slowly consider getting the above subset to stable</p>



<a name="202925450"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/202925450" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#202925450">(Jul 05 2020 at 15:13)</a>:</h4>
<p>As always, I might be missing something here, so cc <span class="user-mention" data-user-id="119009">@eddyb</span> <span class="user-mention" data-user-id="121053">@varkor</span> who probably have some more concerns.</p>



<a name="202925520"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/202925520" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#202925520">(Jul 05 2020 at 15:15)</a>:</h4>
<p>I think on Zulip they're <span class="user-mention" data-user-id="256759">@boats</span>? I could be wrong though</p>



<a name="202925533"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/202925533" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#202925533">(Jul 05 2020 at 15:16)</a>:</h4>
<p><span class="user-mention silent" data-user-id="216206">lcnr</span> <a href="#narrow/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics/near/202925365">said</a>:</p>
<blockquote>
<ul>
<li>only constants and params as generic arguments, i.e. we still forbid <code>[u8; size_of::&lt;T&gt;()]</code> and <code>[u8; N + 1]</code>.</li>
</ul>
</blockquote>
<p>this is the sad one for me</p>



<a name="202925574"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/202925574" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#202925574">(Jul 05 2020 at 15:16)</a>:</h4>
<p>I guess it makes sense but I didn't expect us to have to make that compromise</p>



<a name="202925582"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/202925582" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#202925582">(Jul 05 2020 at 15:17)</a>:</h4>
<p>anything more requires both lazy norm and better const wf (design + impl work), so I don't think we get to that quickly</p>



<a name="202927632"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/202927632" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> boats <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#202927632">(Jul 05 2020 at 16:16)</a>:</h4>
<p>This seems like a set of limitations that is pretty easy to delimit. With good diagnostics when someone tries to step outside of it, it could be a reasonable MVP</p>



<a name="203107064"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203107064" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> James Munns <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203107064">(Jul 07 2020 at 14:09)</a>:</h4>
<p>As a potential user, even just having const generic arrays would make a LOT of no_std/embedded applications much nicer very quickly.</p>



<a name="203107096"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203107096" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> James Munns <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203107096">(Jul 07 2020 at 14:09)</a>:</h4>
<p>Especially if those parameters could be used as part of const-fn constructors</p>



<a name="203107440"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203107440" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> James Munns <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203107440">(Jul 07 2020 at 14:12)</a>:</h4>
<p>For example, <code>bbqueue</code>: <a href="https://docs.rs/bbqueue/0.4.8/bbqueue/#static-usage">https://docs.rs/bbqueue/0.4.8/bbqueue/#static-usage</a></p>
<p>We have to do a big dance to get const-fn constuctors over <code>GenericArray</code> types:</p>
<ul>
<li><a href="https://github.com/jamesmunns/bbqueue/blob/master/core/src/bbbuffer.rs#L22-L27">https://github.com/jamesmunns/bbqueue/blob/master/core/src/bbbuffer.rs#L22-L27</a></li>
<li><a href="https://github.com/jamesmunns/bbqueue/blob/master/core/src/bbbuffer.rs#L206-L242">https://github.com/jamesmunns/bbqueue/blob/master/core/src/bbbuffer.rs#L206-L242</a></li>
</ul>



<a name="203613013"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203613013" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> varkor <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203613013">(Jul 11 2020 at 20:54)</a>:</h4>
<p>I wouldn't have an objection to trying to stabilise a small subset like this. I don't think there would be technical issues for a small subset: we've effectively been using it in the standard library for quite a long time now.</p>



<a name="203613016"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203613016" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> varkor <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203613016">(Jul 11 2020 at 20:54)</a>:</h4>
<p>I think Centril was the only one who objected to this, and they're not involved at the moment.</p>



<a name="203613082"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203613082" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203613082">(Jul 11 2020 at 20:56)</a>:</h4>
<p>I'd love to see <code>min_const_generics</code> get stabilized.</p>



<a name="203613088"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203613088" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203613088">(Jul 11 2020 at 20:56)</a>:</h4>
<p>I think the first step would be someone codifying exactly what that subset would be, based on knowledge of what's working reliably that we'd be willing to commit to.</p>



<a name="203620337"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203620337" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203620337">(Jul 12 2020 at 00:39)</a>:</h4>
<p>it's basically universal quantification over concrete constants, with 0 computation, right?</p>



<a name="203620341"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203620341" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203620341">(Jul 12 2020 at 00:40)</a>:</h4>
<p>we could've probably done this ages ago, but no crying over spilt features etc.</p>



<a name="203620396"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203620396" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203620396">(Jul 12 2020 at 00:41)</a>:</h4>
<p>we just need to make sure we don't allow any types <em>or values</em> that are not pure integers (or modelable as ADT-ish trees with integer leaves)</p>



<a name="203620451"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203620451" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203620451">(Jul 12 2020 at 00:42)</a>:</h4>
<p>in the interest of being able to compare two concrete values for equality (in order to compare two types which refer to them for equality)</p>



<a name="203620474"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203620474" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203620474">(Jul 12 2020 at 00:43)</a>:</h4>
<p>one thing I'll say is we should be able allow <code>Foo&lt;"bar"&gt;</code> from the start. which would be enough for some metaprogramming usecases</p>



<a name="203620527"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203620527" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203620527">(Jul 12 2020 at 00:44)</a>:</h4>
<p>so maybe we should focus on full printing and mangling for concrete values (it's not a lot of work, just someone has to plumb them together) - and <span class="user-mention" data-user-id="124288">@oli</span>'s MCP for "integer trees" representation would be great to have just so we know we can 100% trust type-level constants</p>



<a name="203620541"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203620541" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203620541">(Jul 12 2020 at 00:45)</a>:</h4>
<p>if necessary, we can disallow using user-defined types even if "structural match" might make sense to use as the condition</p>



<a name="203620595"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203620595" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203620595">(Jul 12 2020 at 00:46)</a>:</h4>
<p>but the real split is between <code>Foo&lt;123, N, M&gt;</code> and <code>Bar&lt;{N+M}&gt;</code>, the latter requiring ways of constraining that the expression successfully evalutes, which haven't even been designed yet</p>



<a name="203620670"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203620670" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203620670">(Jul 12 2020 at 00:48)</a>:</h4>
<p>maybe people disagree and want just integers (or even just <code>usize</code>) - that's probably fine as well, but I'll note that value checking is still required to avoid something like <code>Foo&lt;{ &amp;() as *const _ as usize }&gt;</code> where an integer constant exists with a non-integer value</p>



<a name="203621322"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203621322" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203621322">(Jul 12 2020 at 01:10)</a>:</h4>
<p><span class="user-mention" data-user-id="119009">@eddyb</span> Just to confirm, if we had this version of <code>min_const_generics</code>, you'd still be able to get the constant value for CTFE, you just couldn't do computation and put the result back in the type system, right?</p>



<a name="203621342"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203621342" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203621342">(Jul 12 2020 at 01:11)</a>:</h4>
<p><span class="user-mention" data-user-id="239881">@Josh Triplett</span> you could do CTFE for the value of a const generic argument, just not dependent on generic parameters</p>



<a name="203621398"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203621398" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203621398">(Jul 12 2020 at 01:12)</a>:</h4>
<p>so you could still have <code>Foo&lt;{compute_this()}&gt;</code> but not <code>Foo&lt;{size_of::&lt;T&gt;()}&gt;</code> where <code>T</code> is a type parameter (would work fine with a concrete type)</p>



<a name="203621401"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203621401" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203621401">(Jul 12 2020 at 01:12)</a>:</h4>
<p>Ah, so <code>const { size_of::&lt;ConcreteType&gt;() * 8 }</code> would be OK?</p>



<a name="203621407"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203621407" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203621407">(Jul 12 2020 at 01:12)</a>:</h4>
<p>yes (although we don't use the <code>const</code> keyword)</p>



<a name="203621413"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203621413" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203621413">(Jul 12 2020 at 01:13)</a>:</h4>
<p>There's been discussion about <code>const { ... }</code> blocks.</p>



<a name="203621415"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203621415" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203621415">(Jul 12 2020 at 01:13)</a>:</h4>
<p><span class="user-mention" data-user-id="239881">@Josh Triplett</span> IOW, pretty much anything that works today in an array length</p>



<a name="203621422"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203621422" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203621422">(Jul 12 2020 at 01:13)</a>:</h4>
<p>yeah, I mean that const generics don't use that syntax</p>



<a name="203621424"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203621424" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203621424">(Jul 12 2020 at 01:13)</a>:</h4>
<p>Ah.</p>



<a name="203621429"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203621429" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203621429">(Jul 12 2020 at 01:13)</a>:</h4>
<p>the <code>const {...}</code> syntax is explicitly in (potentially-)runtime code</p>



<a name="203621475"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203621475" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203621475">(Jul 12 2020 at 01:14)</a>:</h4>
<p>Can you get the generic parameter <em>out</em> and do CTFE on it, as long as you don't put it back <em>into</em> the type system?</p>



<a name="203621489"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203621489" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203621489">(Jul 12 2020 at 01:14)</a>:</h4>
<p>depends where</p>



<a name="203621494"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203621494" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203621494">(Jul 12 2020 at 01:14)</a>:</h4>
<p>I believe you can do that in associated <code>const</code>s. and definitely in <code>fn</code>s</p>



<a name="203621506"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203621506" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203621506">(Jul 12 2020 at 01:15)</a>:</h4>
<p>Well, to give the simplest example: <code>const fn foo&lt;T, N&gt;(slice: [T; N]) -&gt; usize { N * 42 }</code>.</p>



<a name="203621510"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203621510" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203621510">(Jul 12 2020 at 01:15)</a>:</h4>
<p>yes</p>



<a name="203621512"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203621512" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203621512">(Jul 12 2020 at 01:15)</a>:</h4>
<p>Awesome.</p>



<a name="203621560"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203621560" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203621560">(Jul 12 2020 at 01:16)</a>:</h4>
<p>note that <code>[...; N * 42]</code> expressions wouldn't work because that ends up with a <code>[_; N * 42]</code> type</p>



<a name="203621565"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203621565" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203621565">(Jul 12 2020 at 01:16)</a>:</h4>
<p>Yeah, I can understand that.</p>



<a name="203630953"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203630953" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203630953">(Jul 12 2020 at 06:42)</a>:</h4>
<p>If it's not a crazy amount of extra work, I'd like to strongly request that the minimal version support user enums that are <code>repr(some_primitive)</code>. And of course that you be allowed to do <code>val as prim_type</code> to turn it into its integer form.</p>
<p>Or, in the "just <code>usize</code>" case, of course limit it to user enums that are <code>repr(usize)</code>.</p>



<a name="203659907"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203659907" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203659907">(Jul 12 2020 at 20:36)</a>:</h4>
<p><span class="user-mention" data-user-id="224471">@Lokathor</span> <code>repr(X)</code> doesn't really matter here, the only distinction we could make is data-less enums</p>



<a name="203659909"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203659909" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203659909">(Jul 12 2020 at 20:36)</a>:</h4>
<p>aka "C-like"</p>



<a name="203659923"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203659923" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203659923">(Jul 12 2020 at 20:37)</a>:</h4>
<p>but I'd prefer if we did all user-defined types at once. or at least, had the <code>#[derive(PartialEq, Eq)]</code> ("structural match") requirement from the start</p>



<a name="203666393"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203666393" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203666393">(Jul 12 2020 at 23:32)</a>:</h4>
<p>Well, all C-like enums then.</p>



<a name="203666410"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203666410" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203666410">(Jul 12 2020 at 23:33)</a>:</h4>
<p>(I had to check the reference just now to be reminded that you can repr(prim) on a non-C-like enum, and you just get an unspecified layout, without even a warning, which seems... less than good).</p>



<a name="203667586"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203667586" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203667586">(Jul 13 2020 at 00:08)</a>:</h4>
<p><span class="user-mention" data-user-id="224471">@Lokathor</span> if the reference says that, then the reference is lying</p>



<a name="203667593"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203667593" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203667593">(Jul 13 2020 at 00:08)</a>:</h4>
<p>which I've seen people insist is not a problem anymore, but for a long time we learned to tell people "yeah the reference is outdated, ignore it"</p>



<a name="203668384"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203668384" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203668384">(Jul 13 2020 at 00:30)</a>:</h4>
<p><a href="https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2018&amp;gist=e1f0ffecfe1037f14037c7356fea51cc">https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2018&amp;gist=e1f0ffecfe1037f14037c7356fea51cc</a><br>
The size of <code>i32</code> is not 8, so the reference seems accurate. It seems to have just done "something", and it gives no warning that the actual type generated doesn't have an <code>i32</code> layout.</p>



<a name="203673484"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203673484" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203673484">(Jul 13 2020 at 02:52)</a>:</h4>
<p><span class="user-mention" data-user-id="224471">@Lokathor</span> sorry I didn't get back to you earlier, got distracted. <code>repr(iN)</code> controls the tag representation</p>



<a name="203673490"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203673490" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203673490">(Jul 13 2020 at 02:53)</a>:</h4>
<p>we actually define the entire layout if you use <code>repr(C)</code>, <code>repr(iN)</code> or both (<code>repr(C, iN)</code>)</p>



<a name="203673496"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203673496" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203673496">(Jul 13 2020 at 02:53)</a>:</h4>
<p><span class="user-mention" data-user-id="224471">@Lokathor</span> <a href="https://github.com/rust-lang/rfcs/pull/2195">https://github.com/rust-lang/rfcs/pull/2195</a></p>



<a name="203673498"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203673498" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203673498">(Jul 13 2020 at 02:53)</a>:</h4>
<p>oh, well i do love when the reference is out of date</p>



<a name="203673548"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203673548" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203673548">(Jul 13 2020 at 02:54)</a>:</h4>
<p>not sure if <a href="https://github.com/rust-lang/rfcs/blob/master/text/2195-really-tagged-unions.md">https://github.com/rust-lang/rfcs/blob/master/text/2195-really-tagged-unions.md</a> is itself outdated but it might be more useful than the reference</p>



<a name="203673557"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203673557" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203673557">(Jul 13 2020 at 02:55)</a>:</h4>
<p>so yeah you've been able to do FFI using Rust enums for a couple years now</p>



<a name="203673568"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203673568" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203673568">(Jul 13 2020 at 02:55)</a>:</h4>
<p>maybe we need PSAs for stuff like this, maybe some people still use <code>union</code>s (or worse) for FFI when <code>enum</code> would work</p>



<a name="203673625"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203673625" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203673625">(Jul 13 2020 at 02:56)</a>:</h4>
<p>I have only one place I'd even maybe use this knowledge, but it's taking in data from C so I wouldn't actually switch from union (the current code) to enum.</p>



<a name="203674129"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203674129" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203674129">(Jul 13 2020 at 03:11)</a>:</h4>
<p>I mean it's intended for that purpose, yes (the difference between <code>repr(C, iN)</code> and <code>repr(iN)</code> is how padding works between the tag and the data, so that we can support both struct-of-tag-and-union and union-of-structs-each-with-tag styles)</p>



<a name="203674131"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203674131" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203674131">(Jul 13 2020 at 03:11)</a>:</h4>
<p>but this is getting off-topic :P</p>



<a name="203828597"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203828597" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> boats <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203828597">(Jul 14 2020 at 12:48)</a>:</h4>
<p><span class="user-mention silent" data-user-id="119009">eddyb</span> <a href="#narrow/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics/near/203659923">said</a>:</p>
<blockquote>
<p>but I'd prefer if we did all user-defined types at once. or at least, had the <code>#[derive(PartialEq, Eq)]</code> ("structural match") requirement from the start</p>
</blockquote>
<p>Do you think there's any dissensus at all about what user-defined types can be allowed? cc @varkor Basically, we should include the exact subset where all stakeholders have consensus &amp; the implementation is solid.</p>



<a name="203830011"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203830011" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203830011">(Jul 14 2020 at 13:02)</a>:</h4>
<p>I personally fairly strongly believe that we should only support integer types as a quite self contained subset. I don't know by how much the situation will improve once <a href="https://github.com/rust-lang/compiler-team/issues/323">https://github.com/rust-lang/compiler-team/issues/323</a> is implemented, in which case I might also be fine with arrays, references and <code>&amp;str</code>.</p>



<a name="203830210"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203830210" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> boats <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203830210">(Jul 14 2020 at 13:04)</a>:</h4>
<p>Created an internals thread but before seeing lcnr's last comment</p>



<a name="203830220"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203830220" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203830220">(Jul 14 2020 at 13:04)</a>:</h4>
<p>So I do not want <code>#[repr(...)]</code> enums in the initial MVP</p>



<a name="203830250"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203830250" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> boats <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203830250">(Jul 14 2020 at 13:05)</a>:</h4>
<p>We can leave non integer primtiives out of the MVP IMO, and make them the 1.1</p>



<a name="203830400"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203830400" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203830400">(Jul 14 2020 at 13:06)</a>:</h4>
<p><span class="user-mention silent" data-user-id="256759">boats</span> <a href="#narrow/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics/near/203830210">said</a>:</p>
<blockquote>
<p>Created an internals thread but before seeing lcnr's last comment</p>
</blockquote>
<p>do you have a link?</p>



<a name="203830467"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203830467" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203830467">(Jul 14 2020 at 13:07)</a>:</h4>
<p>ah <a href="https://internals.rust-lang.org/t/stabilizing-a-const-generics-mvp/12727">https://internals.rust-lang.org/t/stabilizing-a-const-generics-mvp/12727</a></p>



<a name="203835783"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203835783" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203835783">(Jul 14 2020 at 13:56)</a>:</h4>
<p>I still also have some thoughts on "structural match/eq" in particular in the context of const-generics that I need to write up. I don't fully understand it yet and the parts I do understand lead me to think it can be improved...</p>



<a name="203835827"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203835827" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203835827">(Jul 14 2020 at 13:56)</a>:</h4>
<p>my thoughts are not coherent enough for a blog post so my plan was to open an issue, once I find the time^^</p>



<a name="203851763"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203851763" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203851763">(Jul 14 2020 at 16:02)</a>:</h4>
<p>Allowing integer convertible enums in the minimum version would greatly help SIMD intrinsic abstracting, but if it has to be in the 1.1 then I'll live.</p>



<a name="203869312"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203869312" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203869312">(Jul 14 2020 at 18:27)</a>:</h4>
<p>I would like rustc_args_required_const to be turned into syntax sugar for const generics. It's only used by intrinsics and will never be stable anyways.</p>



<a name="203870393"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203870393" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203870393">(Jul 14 2020 at 18:36)</a>:</h4>
<p>On that point either way is fine, but that change wouldn't let you restrict the caller to the legally allowed const values (as an enum would).</p>



<a name="203870627"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203870627" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203870627">(Jul 14 2020 at 18:38)</a>:</h4>
<p>Actually now that I think about it it's not fine either way: having to put a call argument in turbofish position would be ugly as heck, and we shouldn't make that the main way to do things, even if maybe the alternative way de-sugars to that.</p>



<a name="203882016"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203882016" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203882016">(Jul 14 2020 at 20:16)</a>:</h4>
<p>I wonder if we could support range restrictions with where clauses...</p>



<a name="203882069"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203882069" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> boats <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203882069">(Jul 14 2020 at 20:17)</a>:</h4>
<p>Yea, using const arguments in that way is really interesting and I agree that better support for that pattern without requiring turbofish syntax would be a cool feature if it made sense.</p>



<a name="203882415"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203882415" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203882415">(Jul 14 2020 at 20:20)</a>:</h4>
<p><span class="user-mention" data-user-id="143274">@Amanieu</span> so uhhhh did you see when I realized how "required const" was used and I got scared we made a huge mistake?</p>



<a name="203882445"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203882445" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203882445">(Jul 14 2020 at 20:20)</a>:</h4>
<p>for some reason I had previously assumed it was used only on intrinsics, or maybe on unstabilizable functions</p>



<a name="203882515"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203882515" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203882515">(Jul 14 2020 at 20:21)</a>:</h4>
<p>it's not used by intrinsics, it's used by Rust wrappers around intrinsics</p>



<a name="203882549"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203882549" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203882549">(Jul 14 2020 at 20:21)</a>:</h4>
<p>and the only way to really make that work is to replace the wrappers with actual intrinsics</p>



<a name="203882673"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203882673" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203882673">(Jul 14 2020 at 20:22)</a>:</h4>
<p>within the foreseable future, I mean. having regular arguments that behave like generics is either going to be extremely hacky, or one of those "Rust 2.0" things</p>



<a name="203882923"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203882923" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203882923">(Jul 14 2020 at 20:24)</a>:</h4>
<p>at least <span class="user-mention" data-user-id="216206">@lcnr</span>'s recent work makes <em>something</em> possible at all (type-checking the const arg where inference in the parent, e.g. function, is required to know what the const param type is), but it's still much harder for function calls</p>



<a name="203883078"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203883078" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203883078">(Jul 14 2020 at 20:25)</a>:</h4>
<p>to be able to type-check, build the MIR, and evaluate the MIR, in order to plug it into a const generic position in the typesystem, you need to know very early that it's a separate body</p>



<a name="203883185"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203883185" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203883185">(Jul 14 2020 at 20:26)</a>:</h4>
<p>for the "arg required to be const" hack, we can only bypass all that <em>because</em> it never shows up in the typesystem and we can't do monomorphization based on it</p>



<a name="203883252"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203883252" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203883252">(Jul 14 2020 at 20:26)</a>:</h4>
<p><span class="user-mention" data-user-id="143274">@Amanieu</span> okay I think I have a hack for you but you might not like it :P. we can have <code>rustc_args_required_const</code> rewrite the call <em>to a different function</em></p>



<a name="203883378"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203883378" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203883378">(Jul 14 2020 at 20:27)</a>:</h4>
<p>so the type-checking wouldn't be of const generics, it would be of regular arguments, and only as a MIR transformation would we change it from what looks like a runtime call</p>



<a name="203883505"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203883505" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203883505">(Jul 14 2020 at 20:28)</a>:</h4>
<p>this means that instead of being able to type-check a desugared form, the best you'll get is MIR borrowck ICE-ing due to a type mismatch</p>



<a name="203883601"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203883601" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203883601">(Jul 14 2020 at 20:29)</a>:</h4>
<p>this is why I'm considering this different from "desugaring", because it happens pretty late</p>



<a name="203883772"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203883772" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203883772">(Jul 14 2020 at 20:30)</a>:</h4>
<p><span class="user-mention" data-user-id="143274">@Amanieu</span> so basically you'd specify the name of another function in the <code>#[rustc_args_required_const]</code> attribute, and the argument that has to be const is added at the end of the generics, or something, and when you define such a <code>#[rustc_args_required_const]</code> function, you have to get it right or it will ICE your users</p>



<a name="203883910"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203883910" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203883910">(Jul 14 2020 at 20:31)</a>:</h4>
<p>that's what we can do today with the same infra that enforces that the value would be computed at compile-time, and thankfully that "promoted" MIR fragment we can actually reference from type-level constants</p>



<a name="203884222"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203884222" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203884222">(Jul 14 2020 at 20:33)</a>:</h4>
<p>oh another limitation is that the signature can't refer to that const generic, because type inference doesn't know about it (it basically looks like dependent typing without the separate body that e.g. houses <code>g(N)</code> in <code>f::&lt;{g(N)}&gt;</code>)</p>



<a name="203884485"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203884485" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203884485">(Jul 14 2020 at 20:35)</a>:</h4>
<p>maybe long-term we can fuse these concepts somehow (maybe by having type-checking create lightweight <code>DefId</code> + attached body that just refers to an expression in the parent) but for now hacks are the best we can offer I'm afraid</p>



<a name="203884726"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203884726" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203884726">(Jul 14 2020 at 20:37)</a>:</h4>
<p>anyway, as for the <code>#[repr(iN)]</code> stuff - that's irrelevant to being able to cast an <code>enum</code> to an integer AFAIK, the important thing IMO is an opt-in like <code>#[derive(Eq, PartialEq)]</code> that  the <code>==</code> behavior is "boring", to avoid surprises and remain conservative (at least for now)</p>



<a name="203891210"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203891210" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203891210">(Jul 14 2020 at 21:32)</a>:</h4>
<p>True, <code>repr(integer)</code> isn't required to cast the enum to an integer type. I guess what is really needed is to be able to convert the enum value into its integer form so that you can pass it along to the intrinsic being wrapped. So, depending on what that "you can't use the const arg for computation" limit means, it may be a problem.</p>
<p>Since we have gotten more into it than I expected to, let me spell out specifically one example scenario so that we're on the same page. Our example function is this:</p>
<ul>
<li>pub unsafe fn <a href="https://doc.rust-lang.org/core/arch/x86_64/fn._mm_round_ps.html">_mm_round_ps</a>(a: __m128, rounding: i32) -&gt; __m128</li>
</ul>
<p>The second argument (<code>rounding</code>) indicates the rounding mode you want to use for this round operation, and it must be a const. It must be one of 5 specific const values. The full names are unimportant, but they map to the rounding modes Nearest, Neg infinity, Pos infinity, Zero, or "current rounding mode".</p>
<p>In <code>safe_arch</code> we end up with the <a href="https://docs.rs/safe_arch/0.5.0/safe_arch/macro.round_m128.html">round_m128</a> macro, which takes <code>$a:expr,</code> followed by the name of the rounding mode you want as just a literal token. It's not part of an enum type, it's just a literal. If you type the wrong thing then your invocation ends up matching none of the macro branches and you get a compile error complaining about an unexpected token. This gives us "type safety", of a sort, but at the cost of confusing error messages.</p>
<p>Right now the usage looks like</p>
<div class="codehilite"><pre><span></span><code><span class="n">round_m128</span><span class="o">!</span><span class="p">(</span><span class="n">a</span><span class="p">,</span><span class="w"> </span><span class="n">Nearest</span><span class="p">)</span><span class="w"></span>
</code></pre></div>


<p>and if we instead had a const generic function that could accept an enum value it would hopefully look like</p>
<div class="codehilite"><pre><span></span><code><span class="n">round_m128</span><span class="p">(</span><span class="n">a</span><span class="p">,</span><span class="w"> </span><span class="n">Nearest</span><span class="p">)</span><span class="w"></span>
</code></pre></div>


<p>You just take out the <code>!</code> and you're all set. If I understand the discussion properly, the current version of const generics would require the function version to be called with something like</p>
<div class="codehilite"><pre><span></span><code><span class="n">round_m128</span>::<span class="o">&lt;</span><span class="p">{</span><span class="n">Nearest</span><span class="p">}</span><span class="o">&gt;</span><span class="p">(</span><span class="n">a</span><span class="p">)</span><span class="w"></span>
</code></pre></div>


<p>Certainly usable, but also not the best.</p>



<a name="203893066"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203893066" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203893066">(Jul 14 2020 at 21:53)</a>:</h4>
<p>sorry, is that replying to the <code>repr(iN)</code> discussion, or the <code>#[rustc_args_required_const]</code> one?</p>



<a name="203893070"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203893070" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203893070">(Jul 14 2020 at 21:53)</a>:</h4>
<p>if it's "both" that's super confusing</p>



<a name="203893106"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203893106" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203893106">(Jul 14 2020 at 21:53)</a>:</h4>
<p>also, it's not "the current version of const generics", it's the only version ever designed to an extent that is implementable</p>



<a name="203893219"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203893219" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203893219">(Jul 14 2020 at 21:55)</a>:</h4>
<p>const generics intentionally rely on having a syntactical distinction, which regular function arguments simply don't have, in order to "lift" the expression into a separate (unnamed) constant "definition", <em>before</em> type-checking</p>



<a name="203893377"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203893377" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203893377">(Jul 14 2020 at 21:56)</a>:</h4>
<p>if type-checking is the first place where it's known that an expression is being passed to a "<code>const</code> argument", then it's too late to do any lifting that type-checking could then use in the type-system</p>



<a name="203893396"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203893396" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203893396">(Jul 14 2020 at 21:56)</a>:</h4>
<p>Well I started by replying to the repr(iN) thing, but you'd written a lot so I ended up writing a lot myself :P</p>



<a name="203893450"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203893450" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203893450">(Jul 14 2020 at 21:57)</a>:</h4>
<p>alright so you want <code>fn foo(const x: Foo)</code> and also <code>Foo</code> happens to be an <code>enum</code></p>



<a name="203893636"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203893636" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203893636">(Jul 14 2020 at 21:59)</a>:</h4>
<p>Well, yeah, i don't know anything about the compiler, but basically as a <em>user of a function</em> the <code>rustc_args_required_const</code> system is actually a better way to interact with a function</p>



<a name="203893637"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203893637" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203893637">(Jul 14 2020 at 21:59)</a>:</h4>
<p>the unstable-only workaround for <code>#[rustc_args_required_const]</code> that I mentioned above, would redirect the public regular-looking function to a private const-generic one, so you will indeed be limited by what const generics accept. but also you wouldn't care about things being stabilized because <code>#[rustc_args_required_const]</code> is perma-unstable and there is no design or path forward for "const argurments"</p>



<a name="203893762"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203893762" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203893762">(Jul 14 2020 at 22:00)</a>:</h4>
<p>deeply unfortunate</p>



<a name="203893812"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203893812" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203893812">(Jul 14 2020 at 22:01)</a>:</h4>
<p>frankly, if we do want <code>fn foo(const x: Foo)</code> to work, we should start trying to make rustc dependent-typing-friendly</p>



<a name="203893846"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203893846" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203893846">(Jul 14 2020 at 22:01)</a>:</h4>
<p>which means breaking some of the barriers between the value level and the type level</p>



<a name="203893913"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203893913" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203893913">(Jul 14 2020 at 22:02)</a>:</h4>
<p>sounds like an itty bitty RFC that no one would have strong feelings about.</p>



<a name="203893917"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203893917" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203893917">(Jul 14 2020 at 22:02)</a>:</h4>
<p>anything I can think of that's not a pile of hacks feels insurmountable</p>



<a name="203893929"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203893929" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203893929">(Jul 14 2020 at 22:02)</a>:</h4>
<p><span class="user-mention" data-user-id="224471">@Lokathor</span> to be clear: I mean the implementation</p>



<a name="203893950"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203893950" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203893950">(Jul 14 2020 at 22:02)</a>:</h4>
<p>ah, so it wouldn't introduce it all to the language?</p>



<a name="203894282"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203894282" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203894282">(Jul 14 2020 at 22:06)</a>:</h4>
<p>yeah, I'm talking about redesigning parts of the typesystem implementation to more readily allow referring to values</p>



<a name="203894307"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203894307" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203894307">(Jul 14 2020 at 22:06)</a>:</h4>
<p>right now it heavily relies on very early lifting, with one exception being promoted MIR fragments (but typeck can't exactly make use of those)</p>



<a name="203894495"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203894495" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203894495">(Jul 14 2020 at 22:09)</a>:</h4>
<p>the current situation is similar to how Haskell has a syntax for making a value into effectively a type where the <em>kind</em> of that type would be called roughly e.g. <code>const i32</code> Rust, and that's very much different from dependent typing</p>



<a name="203922425"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203922425" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203922425">(Jul 15 2020 at 07:10)</a>:</h4>
<p>longer-term I feel like dataless enums shouldn't be hard to represent in the "integer tree" we are moving towards, but I also feel like we should get some basic experience with integers and product types before we move to more complex sum types ;)</p>



<a name="203922438"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203922438" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203922438">(Jul 15 2020 at 07:10)</a>:</h4>
<p>(in terms of stabilizaiton, that is. on nightly miri is probably more than prepared enough already for all that.)</p>



<a name="203925498"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203925498" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203925498">(Jul 15 2020 at 07:53)</a>:</h4>
<p><span class="user-mention" data-user-id="120791">@RalfJ</span> I mean, enum variants are trivial to support? there's not much to do in the first place</p>



<a name="203926906"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203926906" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203926906">(Jul 15 2020 at 08:12)</a>:</h4>
<p>I mean I'd hope so but I prefer to be cautious I guess^^</p>



<a name="203927117"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203927117" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203927117">(Jul 15 2020 at 08:14)</a>:</h4>
<p>the "structural match" requirement and checking that the value doesn't contain anything weird are the scary bits to me, and the latter is mostly subsumed by the conversion to the "ADT tree with integer leaves" (not sure I like how it keeps getting shortened to "integer tree" :P)</p>



<a name="203927169"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203927169" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203927169">(Jul 15 2020 at 08:15)</a>:</h4>
<p>structural match strikes fear into the hearts of even the strongest warriors</p>



<a name="203927989"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203927989" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203927989">(Jul 15 2020 at 08:25)</a>:</h4>
<p><span class="user-mention" data-user-id="119009">@eddyb</span> we can do ATWIL for shortening it if you prefer, but I prefer integer tree over acronyms</p>



<a name="203928042"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203928042" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203928042">(Jul 15 2020 at 08:26)</a>:</h4>
<p>lol</p>



<a name="203928047"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203928047" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203928047">(Jul 15 2020 at 08:26)</a>:</h4>
<p>I think "integer" isn't the most important part</p>



<a name="203928064"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203928064" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203928064">(Jul 15 2020 at 08:26)</a>:</h4>
<p>I'd call it ADT tree (and just imagine an inductive <code>Nat</code> definition)</p>



<a name="203928076"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203928076" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203928076">(Jul 15 2020 at 08:26)</a>:</h4>
<p>or "pure value tree" idk</p>



<a name="203928095"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203928095" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203928095">(Jul 15 2020 at 08:27)</a>:</h4>
<p>valtree is ok <span aria-label="slight smile" class="emoji emoji-1f642" role="img" title="slight smile">:slight_smile:</span></p>



<a name="203928109"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203928109" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203928109">(Jul 15 2020 at 08:27)</a>:</h4>
<p>valtralla</p>



<a name="203928117"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203928117" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203928117">(Jul 15 2020 at 08:27)</a>:</h4>
<p>(I'm so sorry,)</p>



<a name="203928701"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203928701" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203928701">(Jul 15 2020 at 08:35)</a>:</h4>
<p>I like valtree</p>



<a name="203934533"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203934533" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> boats <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203934533">(Jul 15 2020 at 09:47)</a>:</h4>
<p>@lcnr I'm still a little unclear on what can't be allowed in constraints without lazy normalization.</p>



<a name="203934614"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203934614" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> boats <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203934614">(Jul 15 2020 at 09:48)</a>:</h4>
<p>The example you posted doesn't cause any errors on nightly: <a href="https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=8e5d2be7fd6ddb4790083e0c0378ef8a">https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=8e5d2be7fd6ddb4790083e0c0378ef8a</a></p>



<a name="203934716"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203934716" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> boats <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203934716">(Jul 15 2020 at 09:49)</a>:</h4>
<p>And since on stable you can already use a constant in a where clause by doing <code>[T; 0]: Default</code> (for example), it can't just be any constant showing up in a where clause, but that's all your example shows</p>



<a name="203934841"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203934841" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> boats <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203934841">(Jul 15 2020 at 09:50)</a>:</h4>
<p>Is it meant to be just the use of free const parameters in where clauses?</p>



<a name="203934865"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203934865" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> boats <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203934865">(Jul 15 2020 at 09:51)</a>:</h4>
<p><span class="user-mention" data-user-id="216206">@lcnr</span> ^^ (sorry I'm bad at zulip)</p>



<a name="203934935"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203934935" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203934935">(Jul 15 2020 at 09:52)</a>:</h4>
<p>Yeah, you are right</p>



<a name="203934949"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203934949" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203934949">(Jul 15 2020 at 09:52)</a>:</h4>
<p><span class="user-mention silent" data-user-id="256759">boats</span> <a href="#narrow/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics/near/203934614">said</a>:</p>
<blockquote>
<p>The example you posted doesn't cause any errors on nightly: <a href="https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=8e5d2be7fd6ddb4790083e0c0378ef8a">https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=8e5d2be7fd6ddb4790083e0c0378ef8a</a></p>
</blockquote>
<p>This works because<code>#![feature(const_generics)]</code> automatically activates lazy norm</p>



<a name="203934962"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203934962" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203934962">(Jul 15 2020 at 09:52)</a>:</h4>
<p>Tested it locally</p>



<a name="203934987"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203934987" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203934987">(Jul 15 2020 at 09:53)</a>:</h4>
<p>See <a href="#narrow/stream/131828-t-compiler/topic/lazy.20norm.20const.20parent.20generics.20hack/near/203899955">https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/lazy.20norm.20const.20parent.20generics.20hack/near/203899955</a></p>



<a name="203934997"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203934997" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203934997">(Jul 15 2020 at 09:53)</a>:</h4>
<p>I forgot that we currently use a hack to evade the need for lazy norm</p>



<a name="203935017"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203935017" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203935017">(Jul 15 2020 at 09:53)</a>:</h4>
<p>so we probably can't stabilize const generics without first stabilizing lazy norm first</p>



<a name="203935070"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203935070" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203935070">(Jul 15 2020 at 09:54)</a>:</h4>
<p>which means that we don't really have to restrict bounds after all</p>



<a name="203935388"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203935388" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> boats <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203935388">(Jul 15 2020 at 09:58)</a>:</h4>
<p>But isn't this only an issue if we use free parameters?</p>



<a name="203935520"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203935520" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203935520">(Jul 15 2020 at 10:00)</a>:</h4>
<p>it's a problem if we use <code>impl&lt;T&gt; From&lt;[u8; 1 &lt;&lt; 2]&gt; for IpAddr&lt;T&gt;</code> I think. We can't really decide when the parent generics are needed, so we currently always supply them</p>



<a name="203935548"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203935548" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203935548">(Jul 15 2020 at 10:00)</a>:</h4>
<p>i.e. getting const generics to work without lazy norm can very easily break stable code</p>



<a name="203935568"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203935568" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203935568">(Jul 15 2020 at 10:01)</a>:</h4>
<p>am currently looking into this... we previously didn't have a clear example of stable code which breaks without lazy norm</p>



<a name="203935929"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203935929" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> boats <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203935929">(Jul 15 2020 at 10:05)</a>:</h4>
<p>Yea I'm not able to find an example (based on eddy's comment in the other zulip thread) that doesn't work. e.g. <a href="https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=5ceb2d8f660da0488d796dae2116a44c">https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=5ceb2d8f660da0488d796dae2116a44c</a> is fine</p>



<a name="203936040"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203936040" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> boats <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203936040">(Jul 15 2020 at 10:06)</a>:</h4>
<p>Isn't this covered by not allowing any free type or const parameters in these expressions?</p>



<a name="203936222"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203936222" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203936222">(Jul 15 2020 at 10:08)</a>:</h4>
<p>the problem is that we currently don't supply the parent generics to array lengths, which is why <a href="https://github.com/rust-lang/rust/issues/43408">https://github.com/rust-lang/rust/issues/43408</a> and its duplicates exist</p>



<a name="203936231"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203936231" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203936231">(Jul 15 2020 at 10:09)</a>:</h4>
<p>This ICEs because of this:</p>
<div class="codehilite"><pre><span></span><code><span class="k">pub</span><span class="w"> </span><span class="k">const</span><span class="w"> </span><span class="k">fn</span> <span class="nf">sof</span><span class="o">&lt;</span><span class="n">T</span>:<span class="o">?</span><span class="nb">Sized</span><span class="o">&gt;</span><span class="p">()</span><span class="w"> </span>-&gt; <span class="kt">usize</span> <span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="mi">10</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
<span class="k">fn</span> <span class="nf">to_byte_array</span><span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="p">()</span><span class="w"> </span>-&gt; <span class="p">[</span><span class="kt">u8</span><span class="p">;</span><span class="w"> </span><span class="n">sof</span>::<span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="p">()]</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">     </span><span class="n">panic</span><span class="o">!</span><span class="p">()</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="203936355"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203936355" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203936355">(Jul 15 2020 at 10:10)</a>:</h4>
<p>To use const generics, we now supply the parent generics (<code>T</code>) to the unevaluated const <code>1 &lt;&lt; 2</code> in my above example.</p>



<a name="203936357"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203936357" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203936357">(Jul 15 2020 at 10:10)</a>:</h4>
<p><span class="user-mention" data-user-id="256759">@boats</span> what <span class="user-mention" data-user-id="216206">@lcnr</span> said, you need to enable "correct generics in scope" without enabling lazy normalization</p>



<a name="203936364"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203936364" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203936364">(Jul 15 2020 at 10:10)</a>:</h4>
<p>AFAICT there's no way to do this currently without changing the compiler</p>



<a name="203936377"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203936377" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203936377">(Jul 15 2020 at 10:11)</a>:</h4>
<p>presumably because we wanted <code>#![feature(const_generics)]</code> to "just work"</p>



<a name="203936396"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203936396" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203936396">(Jul 15 2020 at 10:11)</a>:</h4>
<p><span class="user-mention silent" data-user-id="119009">eddyb</span> <a href="#narrow/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics/near/203936364">said</a>:</p>
<blockquote>
<p>AFAICT there's no way to do this currently without changing the compiler</p>
</blockquote>
<p>It mostly works, until it doesn't <span aria-label="cry" class="emoji emoji-1f622" role="img" title="cry">:cry:</span> and "until it doesn't" include stable code</p>



<a name="203936398"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203936398" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> boats <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203936398">(Jul 15 2020 at 10:11)</a>:</h4>
<p>Right but we're already scoping down to not allow use of type parameters in the MVP</p>



<a name="203936428"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203936428" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203936428">(Jul 15 2020 at 10:11)</a>:</h4>
<p>sure, we just have to be even stricter than that and say that the expression is either the name of a const generic param, or doesn't see parameters in scope at all</p>



<a name="203936495"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203936495" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203936495">(Jul 15 2020 at 10:12)</a>:</h4>
<p><span class="user-mention" data-user-id="119009">@eddyb</span> We could bodge this by only supplying generic params if one of these params is a const param <span aria-label="laughter tears" class="emoji emoji-1f602" role="img" title="laughter tears">:laughter_tears:</span></p>



<a name="203936511"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203936511" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> boats <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203936511">(Jul 15 2020 at 10:12)</a>:</h4>
<p>It's already either an identity expression or an expression which doesn't use the parameter. What is the difference with "doesn't see"?</p>



<a name="203936514"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203936514" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203936514">(Jul 15 2020 at 10:12)</a>:</h4>
<p>but then it's easy to break it</p>



<a name="203936522"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203936522" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203936522">(Jul 15 2020 at 10:12)</a>:</h4>
<p><span class="user-mention" data-user-id="256759">@boats</span> in terms of what the compiler passes around even when not used</p>



<a name="203936536"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203936536" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203936536">(Jul 15 2020 at 10:13)</a>:</h4>
<p>think like a closure that doesn't really depend on the parent <code>fn</code>'s generics</p>



<a name="203936550"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203936550" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203936550">(Jul 15 2020 at 10:13)</a>:</h4>
<p>they are still tracked everywhere</p>



<a name="203936562"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203936562" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> boats <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203936562">(Jul 15 2020 at 10:13)</a>:</h4>
<p>But how does that impact the exposed surface area? Trait resolution?</p>



<a name="203936598"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203936598" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203936598">(Jul 15 2020 at 10:14)</a>:</h4>
<p>if <del>it</del> a const expression shows up in where clauses, without lazy normalization, you'll end up with a cyclic dependency</p>



<a name="203936631"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203936631" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> boats <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203936631">(Jul 15 2020 at 10:14)</a>:</h4>
<p>what is "it"?</p>



<a name="203936632"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203936632" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203936632">(Jul 15 2020 at 10:14)</a>:</h4>
<p>between "bounds in scope" and "normalize this constant expression" (which is found in the bounds in scope, of it self)</p>



<a name="203936664"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203936664" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203936664">(Jul 15 2020 at 10:14)</a>:</h4>
<p>I'm kind of sad we took out the trigger for this, it'd be useful to demonstrate without modifying the compiler</p>



<a name="203936747"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203936747" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203936747">(Jul 15 2020 at 10:16)</a>:</h4>
<p>in the case of your <code>impl</code> there, <code>Foo&lt;T&gt;: From&lt;[U; 1 + 1]&gt;</code> is a "bound in scope" (<code>ParamEnv</code>) of the whole impl, including the <code>1+1</code> expression (so e.g. if you had an associated <code>const</code> in the <code>impl</code>, you could probably use it, lol?)</p>



<a name="203936833"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203936833" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203936833">(Jul 15 2020 at 10:17)</a>:</h4>
<p>and without lazy normalization, we try to eagerly normalize the <code>1 + 1</code>, but type-checking <code>1 + 1</code> eagerly depends on the "bounds in scope" (so that you can check which traits are implemented, <em>just in case you need to</em> etc.)</p>



<a name="203936858"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203936858" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203936858">(Jul 15 2020 at 10:17)</a>:</h4>
<p>lazy normalization breaks the cycle by replacing "just in case you need to" with "only if you need to"</p>



<a name="203936889"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203936889" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> boats <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203936889">(Jul 15 2020 at 10:17)</a>:</h4>
<p>Thanks, I managed to get a cycle: <a href="https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=8cd9fc9808eaf04e119dda2de2ef445a">https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=8cd9fc9808eaf04e119dda2de2ef445a</a></p>



<a name="203936893"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203936893" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203936893">(Jul 15 2020 at 10:17)</a>:</h4>
<p>the only reason a plain literal works is basically a pre-lazy-normalization hack</p>



<a name="203936952"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203936952" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203936952">(Jul 15 2020 at 10:18)</a>:</h4>
<p>that's a <del>normal</del> unavoidable cycle though</p>



<a name="203936963"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203936963" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203936963">(Jul 15 2020 at 10:18)</a>:</h4>
<p>although it partially overlaps with the ones I'm talking about</p>



<a name="203937023"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203937023" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203937023">(Jul 15 2020 at 10:19)</a>:</h4>
<p>the difference is that in what I'm talking about you'd see the <code>param_env</code> query show up, let me check what that's described as</p>



<a name="203937035"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203937035" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> boats <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203937035">(Jul 15 2020 at 10:19)</a>:</h4>
<p>But you've talked about compiler internals, I'm asking what users can witness that would change once lazy const normalization is enabled</p>



<a name="203937080"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203937080" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203937080">(Jul 15 2020 at 10:20)</a>:</h4>
<p>lazy normalization just makes more things work</p>



<a name="203937094"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203937094" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203937094">(Jul 15 2020 at 10:20)</a>:</h4>
<p>(modulo bugs)</p>



<a name="203937136"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203937136" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> boats <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203937136">(Jul 15 2020 at 10:20)</a>:</h4>
<p>What expression is non-cyclical, with no free parameters used in the expression, but still depends on those parameters?</p>



<a name="203937213"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203937213" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> boats <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203937213">(Jul 15 2020 at 10:21)</a>:</h4>
<p>ie what would work that doesn't work now that isn't already excluded by the no free params rule</p>



<a name="203937225"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203937225" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203937225">(Jul 15 2020 at 10:21)</a>:</h4>
<p>without it, if we want to have const generics and not break any existing code, we'd have to come up with a decision for "does this get to see parameters/bounds in scope", likely limited to "this is literally a use of a const generic param"</p>



<a name="203937235"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203937235" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203937235">(Jul 15 2020 at 10:21)</a>:</h4>
<p><span class="user-mention" data-user-id="256759">@boats</span> it's specifically stuff that <em>doesn't</em> mention parameters</p>



<a name="203937241"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203937241" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203937241">(Jul 15 2020 at 10:21)</a>:</h4>
<p>that we're worried about</p>



<a name="203937294"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203937294" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> boats <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203937294">(Jul 15 2020 at 10:22)</a>:</h4>
<p>yea, I'm trying to get a concrete example of that to understand the user impact better</p>



<a name="203937307"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203937307" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203937307">(Jul 15 2020 at 10:22)</a>:</h4>
<p>note that  "syntactically mentions parameters" is an incomplete approximation of "semantically depends on parameters/bounds in scope"</p>



<a name="203937322"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203937322" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> boats <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203937322">(Jul 15 2020 at 10:22)</a>:</h4>
<p>right, that's why I mentioned trait resolution.</p>



<a name="203937361"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203937361" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> boats <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203937361">(Jul 15 2020 at 10:23)</a>:</h4>
<p>I'd be especially worried about an example where method resolution works only because it doesn't see an impl, but lazy normalization could allow it to see an additional impl</p>



<a name="203937369"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203937369" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203937369">(Jul 15 2020 at 10:23)</a>:</h4>
<p>but most examples in the wild are just pure computations AFAIK, so we just need to preserve the behavior until we can do the correct thing</p>



<a name="203937422"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203937422" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203937422">(Jul 15 2020 at 10:24)</a>:</h4>
<p>I mean, it's hard to construct examples because CTFE and no traits, but I can try, I guess?</p>



<a name="203937462"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203937462" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203937462">(Jul 15 2020 at 10:24)</a>:</h4>
<p>so you're not interested in cycle errors but behavioral changes when turning on lazy normalization, due to the "bounds in scope" interactions?</p>



<a name="203937472"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203937472" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203937472">(Jul 15 2020 at 10:24)</a>:</h4>
<p>just to make sure</p>



<a name="203937513"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203937513" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203937513">(Jul 15 2020 at 10:25)</a>:</h4>
<p>that should be easy to demonstrate (if at all possible) without changing the compiler because they shouldn't need const generics and you can otherwise toggle lazy normalization with <code>#![feature(const_generics)]</code>. I'll get it on it now</p>



<a name="203937527"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203937527" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> boats <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203937527">(Jul 15 2020 at 10:25)</a>:</h4>
<p>I'm interested in user impact. So breaking changes in the future would be a showstopper, but cycle errors only seem like a showstopper if they're easy to encounter.</p>



<a name="203937622"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203937622" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> boats <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203937622">(Jul 15 2020 at 10:26)</a>:</h4>
<p>so if "no free params but identity expressions" is enough to avoid breaking changes and easy to encounter bugs, it seems like we could avoid blocking on lazy normalization</p>



<a name="203937656"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203937656" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203937656">(Jul 15 2020 at 10:27)</a>:</h4>
<p>in terms of cycle errors being a showstopper: doing the naive (i.e. w/o lazy normalization) correct thing (of always exposing params/bounds in scope) used to trigger cycles in libcore. the move to <code>const</code>-generic impls (or just <code>#![feature(const_generics)]</code> turning on lazy normalization) have fixed some of that</p>



<a name="203937685"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203937685" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203937685">(Jul 15 2020 at 10:27)</a>:</h4>
<p>I don't remember if we did a crater run but it should be relatively easy, especially for macro generated code, to trip over that</p>



<a name="203937753"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203937753" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203937753">(Jul 15 2020 at 10:28)</a>:</h4>
<p>anyway I'll go try to make a behavioral example now</p>



<a name="203937765"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203937765" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203937765">(Jul 15 2020 at 10:28)</a>:</h4>
<p>oh and this is what you'd see in the kind of cycle error I'm talking about <a href="https://github.com/rust-lang/rust/blob/master/src/librustc_middle/query/mod.rs#L802">https://github.com/rust-lang/rust/blob/master/src/librustc_middle/query/mod.rs#L802</a></p>



<a name="203938376"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203938376" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203938376">(Jul 15 2020 at 10:37)</a>:</h4>
<p><span class="user-mention" data-user-id="256759">@boats</span> done: <a href="https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=257b316bd0aa5382de83ca55757b6121">https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=257b316bd0aa5382de83ca55757b6121</a></p>



<a name="203938394"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203938394" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203938394">(Jul 15 2020 at 10:37)</a>:</h4>
<p>comment out <code>#![feature(const_generics)]</code> to disable lazy normalization</p>



<a name="203938465"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203938465" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203938465">(Jul 15 2020 at 10:38)</a>:</h4>
<p>wasted a bunch of time trying to create an ambiguity between the where clause and the known impl, but the easy thing was just to create an ambiguity between two bounds in scope (which have the same precedence)</p>



<a name="203938485"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203938485" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> boats <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203938485">(Jul 15 2020 at 10:38)</a>:</h4>
<p>makes sense</p>



<a name="203938526"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203938526" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> boats <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203938526">(Jul 15 2020 at 10:38)</a>:</h4>
<p>okay so is the solution to block on lazy normalization or is there a limitation we can provide that avoids the issue?</p>



<a name="203938561"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203938561" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203938561">(Jul 15 2020 at 10:39)</a>:</h4>
<p>I think we can do something</p>



<a name="203938673"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203938673" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203938673">(Jul 15 2020 at 10:40)</a>:</h4>
<p>I'm trying to decide if we need to do one of the refactors that got brought up by <span class="user-mention" data-user-id="216206">@lcnr</span>, <span class="user-mention" data-user-id="121053">@varkor</span> and I elsewhere, which is making <code>rustc_typeck</code> capable of knowing which generics are in scope, all the time (according to its own definition), instead of <code>rustc_resolve</code> for some of the checks that prevent ICEs (such as disallowing <code>struct Foo&lt;T, U = U&gt;(T, U);</code> which would ICE when using e.g. <code>Foo&lt;()&gt;</code>)</p>



<a name="203938721"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203938721" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203938721">(Jul 15 2020 at 10:41)</a>:</h4>
<p>if we do that (which I increasingly regret not doing years ago), and are careful about it, then I think we're golden for making things either error or work, but not ICE</p>



<a name="203938804"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203938804" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203938804">(Jul 15 2020 at 10:42)</a>:</h4>
<p>which means we can keep <code>1 + 1</code> working the exact same way it does today, while special-casing const generic param uses (but not expressions containing them, at least not in the initial stabilization)</p>



<a name="203938829"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203938829" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203938829">(Jul 15 2020 at 10:42)</a>:</h4>
<p>but if we don't want to do even that, we have to be a bit more careful elsewhere</p>



<a name="203938833"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203938833" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203938833">(Jul 15 2020 at 10:42)</a>:</h4>
<p>and presumably handle it in name resolution</p>



<a name="203938876"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203938876" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203938876">(Jul 15 2020 at 10:43)</a>:</h4>
<p>lone <code>N</code> would resolve on stable, const/type parameters nested in an const expression would require <code>#![feature(const_generics)]</code></p>



<a name="203938896"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203938896" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203938896">(Jul 15 2020 at 10:43)</a>:</h4>
<p>and if the user turns that on, they get lazy normalization, which makes everything work</p>



<a name="203938946"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203938946" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203938946">(Jul 15 2020 at 10:44)</a>:</h4>
<p><span class="user-mention" data-user-id="256759">@boats</span> so yeah there's a path forward w/o any refactors</p>



<a name="203938975"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203938975" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203938975">(Jul 15 2020 at 10:44)</a>:</h4>
<p>we just have to make sure we emit an error <em>somewhere</em> before there's a chance of ICEs</p>



<a name="203939102"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203939102" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203939102">(Jul 15 2020 at 10:45)</a>:</h4>
<p>although, this is only for <code>[T; expr]</code> and <code>Foo&lt;{expr}&gt;</code>, I believe <code>[0u8; size_of::&lt;T&gt;()]</code> works already? or maybe I am confusing myself</p>



<a name="203939220"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203939220" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203939220">(Jul 15 2020 at 10:46)</a>:</h4>
<p>ah no, only this does:</p>
<div class="codehilite"><pre><span></span><code><span class="k">fn</span> <span class="nf">foo</span><span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="p">[</span><span class="mi">0</span><span class="k">u8</span><span class="p">;</span><span class="w"> </span><span class="n">std</span>::<span class="n">mem</span>::<span class="n">size_of</span>::<span class="o">&lt;*</span><span class="k">mut</span><span class="w"> </span><span class="n">T</span><span class="o">&gt;</span><span class="p">()];</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="203939296"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203939296" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> boats <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203939296">(Jul 15 2020 at 10:47)</a>:</h4>
<p><span class="user-mention" data-user-id="119009">@eddyb</span> actually, this breakage is already inevitable, because this is fine on stable: <a href="https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2018&amp;gist=8663df490e41c9a237a90de19e4c9ac9">https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2018&amp;gist=8663df490e41c9a237a90de19e4c9ac9</a></p>



<a name="203939363"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203939363" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203939363">(Jul 15 2020 at 10:48)</a>:</h4>
<p>my link above also compiles on stable, no?</p>



<a name="203939368"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203939368" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203939368">(Jul 15 2020 at 10:48)</a>:</h4>
<p>But isn't that fine as <code>u8</code> is a concrete type?</p>



<a name="203939374"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203939374" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> boats <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203939374">(Jul 15 2020 at 10:48)</a>:</h4>
<p>yea, you're right</p>



<a name="203939386"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203939386" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203939386">(Jul 15 2020 at 10:48)</a>:</h4>
<div class="codehilite"><pre><span></span><code><span class="k">fn</span> <span class="nf">foo</span><span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="p">[</span><span class="mi">0</span><span class="k">u8</span><span class="p">;</span><span class="w"> </span><span class="n">std</span>::<span class="n">mem</span>::<span class="n">size_of</span>::<span class="o">&lt;*</span><span class="k">mut</span><span class="w"> </span><span class="n">T</span><span class="o">&gt;</span><span class="p">()];</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="203939402"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203939402" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203939402">(Jul 15 2020 at 10:48)</a>:</h4>
<p>That one is a back compat hazard and imo a problem with the way our generics work</p>



<a name="203939414"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203939414" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203939414">(Jul 15 2020 at 10:48)</a>:</h4>
<p>(sorry I wasn't clearer, I was searching for something that compiles on stable and changes behavior with lazy normalization)</p>



<a name="203939435"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203939435" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203939435">(Jul 15 2020 at 10:49)</a>:</h4>
<p><span class="user-mention" data-user-id="216206">@lcnr</span> what do you mean?</p>



<a name="203939457"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203939457" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203939457">(Jul 15 2020 at 10:49)</a>:</h4>
<p>the size of <code>*mut T</code> is perfectly well-defined given <code>T: Sized</code>, it's the same as the size of <code>usize</code> :P</p>



<a name="203939560"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203939560" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203939560">(Jul 15 2020 at 10:50)</a>:</h4>
<p><span class="user-mention" data-user-id="256759">@boats</span> oh btw I think you can also make lazy normalization not error but instead change runtime behavior</p>



<a name="203939570"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203939570" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> boats <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203939570">(Jul 15 2020 at 10:50)</a>:</h4>
<p>So the sense I have is just disallowing free parameters except for const identity expressions will make the user impact of turning on lazy normalization for consts unimportant</p>



<a name="203939593"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203939593" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> boats <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203939593">(Jul 15 2020 at 10:50)</a>:</h4>
<p>I think its fine for these examples to break, they're clearly wrong code that is also pathological</p>



<a name="203939594"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203939594" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203939594">(Jul 15 2020 at 10:50)</a>:</h4>
<p>by having just <code>Trait&lt;T&gt;</code> instead of <code>Trait&lt;T&gt; + Trait&lt;U&gt;</code> - without lazy normalization, that gets ignored and the <code>Trait&lt;()&gt;</code> impl is used instead</p>



<a name="203939606"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203939606" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203939606">(Jul 15 2020 at 10:51)</a>:</h4>
<p>I'm also fine with breaking these examples, yes</p>



<a name="203939628"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203939628" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203939628">(Jul 15 2020 at 10:51)</a>:</h4>
<p>what I don't want to break is <code>1 + 1 + 1 + 1</code> generated by a macro, in any position</p>



<a name="203939647"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203939647" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203939647">(Jul 15 2020 at 10:51)</a>:</h4>
<p><span class="user-mention" data-user-id="256759">@boats</span> I should've asked earlier, what do you mean by "identity" here?</p>



<a name="203939656"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203939656" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> boats <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203939656">(Jul 15 2020 at 10:51)</a>:</h4>
<p><code>N</code></p>



<a name="203939661"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203939661" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203939661">(Jul 15 2020 at 10:51)</a>:</h4>
<p>aaaah alright, thanks, makes sense</p>



<a name="203939668"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203939668" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> boats <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203939668">(Jul 15 2020 at 10:51)</a>:</h4>
<p>in the original RFC an identity expression is defined that way</p>



<a name="203939713"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203939713" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203939713">(Jul 15 2020 at 10:52)</a>:</h4>
<p>shows you how well I remember the RFC :P</p>



<a name="203939737"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203939737" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203939737">(Jul 15 2020 at 10:52)</a>:</h4>
<p>then yes I agree with you, I think that's the setup I was describing above</p>



<a name="203939782"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203939782" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203939782">(Jul 15 2020 at 10:53)</a>:</h4>
<p>where "disallowing" presumably means "refuse to succeed name-resolving generic parameter names", that is, not anything subtler like whether bounds are in scope</p>



<a name="203939810"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203939810" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> boats <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203939810">(Jul 15 2020 at 10:53)</a>:</h4>
<p>yea thats what I mean</p>



<a name="203939814"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203939814" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203939814">(Jul 15 2020 at 10:53)</a>:</h4>
<p>(I've used more ambiguous words in the past like "exposing", that's why I'm trying to make sure I don't repeat that here)</p>



<a name="203939886"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203939886" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> boats <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203939886">(Jul 15 2020 at 10:54)</a>:</h4>
<p>My belief is changing the behavior of subtler things to be more correct will only break pathological examples that are already expressible on stable</p>



<a name="203939961"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203939961" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> boats <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203939961">(Jul 15 2020 at 10:55)</a>:</h4>
<p>I mean it doesn't really make sense that const generics would change anything because consts can already be used in these positions by way of array types ofc</p>



<a name="203940009"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203940009" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203940009">(Jul 15 2020 at 10:55)</a>:</h4>
<p>alright seems like we agree on the minimum stabilizable configuration</p>



<a name="203940128"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203940128" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203940128">(Jul 15 2020 at 10:56)</a>:</h4>
<p><span class="user-mention silent" data-user-id="119009">eddyb</span> <a href="#narrow/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics/near/203939435">said</a>:</p>
<blockquote>
<p><span class="user-mention silent" data-user-id="216206">lcnr</span> what do you mean?</p>
</blockquote>
<p>This works:</p>



<a name="203940165"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203940165" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203940165">(Jul 15 2020 at 10:56)</a>:</h4>
<div class="codehilite"><pre><span></span><code><span class="k">const</span><span class="w"> </span><span class="k">fn</span> <span class="nf">no_use</span><span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="p">()</span><span class="w"> </span>-&gt; <span class="kt">usize</span> <span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">if</span><span class="w"> </span><span class="kc">false</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="n">std</span>::<span class="n">mem</span>::<span class="n">size_of</span>::<span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="p">()</span><span class="w"></span>
<span class="w">    </span><span class="p">}</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="mi">42</span><span class="w"></span>
<span class="w">    </span><span class="p">}</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
<span class="k">fn</span> <span class="nf">foo</span><span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="p">[</span><span class="mi">0</span><span class="k">u8</span><span class="p">;</span><span class="w"> </span><span class="n">no_use</span>::<span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="p">()];</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="203940199"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203940199" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203940199">(Jul 15 2020 at 10:57)</a>:</h4>
<p>yyyyes?</p>



<a name="203940200"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203940200" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203940200">(Jul 15 2020 at 10:57)</a>:</h4>
<p>This doesn't</p>
<div class="codehilite"><pre><span></span><code><span class="k">const</span><span class="w"> </span><span class="k">fn</span> <span class="nf">use</span><span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="p">()</span><span class="w"> </span>-&gt; <span class="kt">usize</span> <span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">if</span><span class="w"> </span><span class="kc">true</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="n">std</span>::<span class="n">mem</span>::<span class="n">size_of</span>::<span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="p">()</span><span class="w"></span>
<span class="w">    </span><span class="p">}</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="mi">42</span><span class="w"></span>
<span class="w">    </span><span class="p">}</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
<span class="k">fn</span> <span class="nf">foo</span><span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="p">[</span><span class="mi">0</span><span class="k">u8</span><span class="p">;</span><span class="w"> </span><span class="k">use</span>::<span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="p">()];</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="203940218"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203940218" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203940218">(Jul 15 2020 at 10:57)</a>:</h4>
<p>meaning that we leak the way a given function is implemented</p>



<a name="203940243"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203940243" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203940243">(Jul 15 2020 at 10:57)</a>:</h4>
<p>I mean we kind of decided not to make CTFE impossible to misuse, for practicality reasons</p>



<a name="203940258"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203940258" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203940258">(Jul 15 2020 at 10:57)</a>:</h4>
<p>cc <span class="user-mention" data-user-id="124288">@oli</span> <span class="user-mention" data-user-id="120791">@RalfJ</span></p>



<a name="203940358"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203940358" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203940358">(Jul 15 2020 at 10:58)</a>:</h4>
<p>but in that case we could avoid descending into <code>const fn use</code> if we don't fully know its generic parameters, maybe?</p>



<a name="203940397"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203940397" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203940397">(Jul 15 2020 at 10:59)</a>:</h4>
<p>although it might already be a breaking change, did we stabilize <code>if</code> in <code>const fn</code> yet?</p>



<a name="203940417"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203940417" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203940417">(Jul 15 2020 at 10:59)</a>:</h4>
<p><span class="user-mention silent" data-user-id="119009">eddyb</span> <a href="#narrow/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics/near/203940397">said</a>:</p>
<blockquote>
<p>although it might already be a breaking change, did we stabilize <code>if</code> in <code>const fn</code> yet?</p>
</blockquote>
<p>on nightly</p>



<a name="203940455"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203940455" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203940455">(Jul 15 2020 at 10:59)</a>:</h4>
<p>so we have a limited time-window for breaking this :P</p>



<a name="203940552"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203940552" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203940552">(Jul 15 2020 at 11:00)</a>:</h4>
<p>we already allow this though</p>
<div class="codehilite"><pre><span></span><code><span class="k">const</span><span class="w"> </span><span class="k">fn</span> <span class="nf">no_use</span><span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="p">()</span><span class="w"> </span>-&gt; <span class="kt">usize</span> <span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="mi">42</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
<span class="k">fn</span> <span class="nf">foo</span><span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="p">[</span><span class="mi">0</span><span class="k">u8</span><span class="p">;</span><span class="w"> </span><span class="n">no_use</span>::<span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="p">()];</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="203940612"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203940612" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203940612">(Jul 15 2020 at 11:01)</a>:</h4>
<p>I would like to change <code>Predicate::ConstEvaluatable</code> to not look into generic functions at all, but that train is probably long gone</p>



<a name="203940660"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203940660" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203940660">(Jul 15 2020 at 11:01)</a>:</h4>
<p>oh right</p>



<a name="203940749"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203940749" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203940749">(Jul 15 2020 at 11:02)</a>:</h4>
<p>although in that case, the <code>const fn</code> participates in the typesystem so presumably you can't change the body to return anything other than <code>42</code></p>



<a name="203940812"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203940812" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203940812">(Jul 15 2020 at 11:03)</a>:</h4>
<p>hmm <span aria-label="sparkles" class="emoji emoji-2728" role="img" title="sparkles">:sparkles:</span> </p>
<div class="codehilite"><pre><span></span><code><span class="k">const</span><span class="w"> </span><span class="k">fn</span> <span class="nf">no_use</span><span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="p">()</span><span class="w"> </span>-&gt; <span class="kt">usize</span> <span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="n">std</span>::<span class="n">mem</span>::<span class="n">size_of</span>::<span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="p">();</span><span class="w"></span>
<span class="w">    </span><span class="mi">42</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="203940869"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203940869" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203940869">(Jul 15 2020 at 11:03)</a>:</h4>
<p>this is more a general concern, I don't really know how many methods like this exist</p>



<a name="203940967"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203940967" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203940967">(Jul 15 2020 at 11:04)</a>:</h4>
<p>anyway I'll leave that stuff to the CTFE people, although I suspect we already made a decision about this in the past</p>



<a name="203940991"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203940991" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203940991">(Jul 15 2020 at 11:04)</a>:</h4>
<p>(either that or <span class="user-mention" data-user-id="124288">@oli</span> and I went rogue for "cool trick" points)</p>



<a name="203941628"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203941628" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203941628">(Jul 15 2020 at 11:12)</a>:</h4>
<p><span class="user-mention" data-user-id="256759">@boats</span> btw I think with this minimal subset, and <span class="user-mention" data-user-id="216206">@lcnr</span>'s most recent endeavor, we can start to have e.g. <code>.array_chunks::&lt;123&gt;()</code> methods on stable :D</p>



<a name="203941684"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203941684" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203941684">(Jul 15 2020 at 11:13)</a>:</h4>
<p>I'm starting to see why <span class="user-mention" data-user-id="121053">@varkor</span> and <span class="user-mention" data-user-id="216206">@lcnr</span> insisted on wishing that into possibility</p>



<a name="203941697"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203941697" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203941697">(Jul 15 2020 at 11:13)</a>:</h4>
<p><span class="user-mention silent" data-user-id="119009">eddyb</span> <a href="#narrow/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics/near/203941628">said</a>:</p>
<blockquote>
<p><span class="user-mention silent" data-user-id="256759">boats</span> btw I think with this minimal subset, and <span class="user-mention silent" data-user-id="216206">lcnr</span>'s most recent endeavor, we can start to have e.g. <code>.array_chunks::&lt;123&gt;()</code> methods on stable :D</p>
</blockquote>
<p>everybody write <code>slice.array_chunks().map(|[a, b]| a + b)</code></p>



<a name="203941701"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203941701" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203941701">(Jul 15 2020 at 11:13)</a>:</h4>
<p>since it greatly benefits API design</p>



<a name="203941712"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203941712" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203941712">(Jul 15 2020 at 11:13)</a>:</h4>
<p>fair lol</p>



<a name="203941731"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203941731" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203941731">(Jul 15 2020 at 11:13)</a>:</h4>
<p>it's so elegant</p>



<a name="203941734"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203941734" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203941734">(Jul 15 2020 at 11:14)</a>:</h4>
<p>but also, wow, that is beautiful</p>



<a name="203944264"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203944264" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203944264">(Jul 15 2020 at 11:45)</a>:</h4>
<p><span class="user-mention silent" data-user-id="119009">eddyb</span> <a href="#narrow/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics/near/203940009">said</a>:</p>
<blockquote>
<p>alright seems like we agree on the minimum stabilizable configuration</p>
</blockquote>
<p>So to sum this up, we do not want to stabilize <code>lazy_normalization_consts</code> for the const generics MCP.</p>
<p>We instead only allow const params in identity expressions, i.e. <code>N</code> and <code>{ N }</code> and cause an error during typeck if generic parameters are used in a different way? We therefore do not have to supply the parent generics to unevaluated consts, sidestepping the need for lazy norm</p>



<a name="203944406"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203944406" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203944406">(Jul 15 2020 at 11:47)</a>:</h4>
<p><span class="user-mention" data-user-id="216206">@lcnr</span> it's easier for now to instead feature-gate in <code>rustc_resolve</code></p>



<a name="203944429"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203944429" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203944429">(Jul 15 2020 at 11:47)</a>:</h4>
<p>otherwise we need to do that refactor to accurately track generics in scope in <code>rustc_typeck::astconv</code></p>



<a name="203944443"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203944443" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203944443">(Jul 15 2020 at 11:47)</a>:</h4>
<p>how can we cleanly gate in a way which allows <code>N</code> but not <code>{ N + 1 }</code> during resolve?</p>



<a name="203944515"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203944515" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203944515">(Jul 15 2020 at 11:48)</a>:</h4>
<p>feature-gate the latter and make a special-case for the former</p>



<a name="203944583"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203944583" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203944583">(Jul 15 2020 at 11:49)</a>:</h4>
<p>as in, feature-gate mentioning generic parameters in <code>TyKind::Array</code> or <code>GenericArg::Const</code> expressions</p>



<a name="203944619"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203944619" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203944619">(Jul 15 2020 at 11:49)</a>:</h4>
<p>and make one exception for "just the name of a const generic"</p>



<a name="203944680"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203944680" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203944680">(Jul 15 2020 at 11:50)</a>:</h4>
<p>it will likely look a bit hacky, but it should be way less work (and presumably less to try and get right) than the refactor</p>



<a name="203944968"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203944968" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203944968">(Jul 15 2020 at 11:52)</a>:</h4>
<p>that means will still keep the ICE on <code>fn foo&lt;T&gt;() -&gt; [u8; std::mem::size_of::&lt;T&gt;()]</code> after const generics is stable?</p>



<a name="203944988"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203944988" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203944988">(Jul 15 2020 at 11:52)</a>:</h4>
<p>but yeah, I understand why this makes sense</p>



<a name="203945037"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203945037" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203945037">(Jul 15 2020 at 11:53)</a>:</h4>
<p>but I just don't want to <span aria-label="cry" class="emoji emoji-1f622" role="img" title="cry">:cry:</span> can't we just wait a few months and I get lazy norm to stable first <span aria-label="sweat smile" class="emoji emoji-1f605" role="img" title="sweat smile">:sweat_smile:</span></p>



<a name="203945218"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203945218" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203945218">(Jul 15 2020 at 11:55)</a>:</h4>
<p><span class="user-mention" data-user-id="216206">@lcnr</span> no, we'd start feature-gating that instead of ICE-ing</p>



<a name="203945241"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203945241" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203945241">(Jul 15 2020 at 11:55)</a>:</h4>
<p>how?</p>



<a name="203945267"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203945267" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203945267">(Jul 15 2020 at 11:55)</a>:</h4>
<p>because it's a type parameter in an array type's length</p>



<a name="203945271"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203945271" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203945271">(Jul 15 2020 at 11:55)</a>:</h4>
<p><code>fn foo&lt;T&gt;() -&gt; [u8; std::mem::size_of::&lt;*mut T&gt;()]</code> already works on stable</p>



<a name="203945280"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203945280" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203945280">(Jul 15 2020 at 11:56)</a>:</h4>
<p>/me squints</p>



<a name="203945341"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203945341" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203945341">(Jul 15 2020 at 11:56)</a>:</h4>
<p>it does not</p>



<a name="203945365"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203945365" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203945365">(Jul 15 2020 at 11:56)</a>:</h4>
<p>note that what I made work a couple months ago is <code>[expr; N]</code> not <code>[type; N]</code></p>



<a name="203945371"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203945371" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203945371">(Jul 15 2020 at 11:56)</a>:</h4>
<p>the "repeat expression" not "array type"</p>



<a name="203945413"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203945413" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203945413">(Jul 15 2020 at 11:57)</a>:</h4>
<p>the array type example fails on both stable and nightly with:</p>
<div class="codehilite"><pre><span></span><code>error: internal compiler error: src/librustc_middle/ty/subst.rs:554:17: type parameter `T/#0` (T/0) out of range when substituting (root type=Some(fn() -&gt; usize {std::mem::size_of::&lt;*mut T&gt;})) substs=[]
</code></pre></div>



<a name="203945429"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203945429" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203945429">(Jul 15 2020 at 11:57)</a>:</h4>
<p>mb</p>



<a name="203945598"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203945598" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203945598">(Jul 15 2020 at 11:58)</a>:</h4>
<p>("repeat expressions" are fine because they can't show up in positions that can lead to cycle errors  - another fact I wish I appreciated years ago <em>sigh</em> - but at least nowadays we have the "const expression depends on generic parameter" error)</p>



<a name="203947273"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203947273" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203947273">(Jul 15 2020 at 12:16)</a>:</h4>
<p>I think the const generics MVP described in <a href="https://internals.rust-lang.org/t/stabilizing-a-const-generics-mvp/12727/9?u=lcnr">https://internals.rust-lang.org/t/stabilizing-a-const-generics-mvp/12727/9?u=lcnr</a> seems good to me <span aria-label="thumbs up" class="emoji emoji-1f44d" role="img" title="thumbs up">:thumbs_up:</span></p>



<a name="203947315"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203947315" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203947315">(Jul 15 2020 at 12:17)</a>:</h4>
<p>I also have to add the mentioned lazy norm breakage as a ui test so I don't forget this in the future</p>



<a name="203948309"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203948309" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Connor Horman <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203948309">(Jul 15 2020 at 12:28)</a>:</h4>
<p>I think at least adding references (and maybe pointers) to const-generics MVP would be useful.<br>
In C++, non-type template parameters allowed references from 98, and while I didn't make use of it often, it certainly was helpful in a few niche cases (for example, emitting static reflection information). A similar, but wider argument could be made about non-data carrying enums. I used that quite a bit as a more type-safe parameter.</p>



<a name="203948620"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203948620" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203948620">(Jul 15 2020 at 12:31)</a>:</h4>
<p>They would be useful, but they are also more complicated to deal with than integers.</p>
<p>We do plan to support them eventually, but at least for me the main priority is getting generic arrays on stable. Mostly focusing on integers for now gets us there faster</p>



<a name="203949620"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203949620" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203949620">(Jul 15 2020 at 12:40)</a>:</h4>
<p><span class="user-mention" data-user-id="257758">@Connor Horman</span> note that pointers could only be allowed if they contain integer addresses</p>



<a name="203949747"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203949747" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203949747">(Jul 15 2020 at 12:42)</a>:</h4>
<p>since that's what pointer equality compares, and we want to avoid <code>Foo&lt;{a}&gt; = Foo&lt;{b}&gt;</code> using a notion of equality different than <code>a == b</code></p>



<a name="203949781"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203949781" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203949781">(Jul 15 2020 at 12:42)</a>:</h4>
<p>(we don't want to rely on the <code>Eq</code> implementations though, just disallow types/values for which it would do something different)</p>



<a name="203949811"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203949811" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203949811">(Jul 15 2020 at 12:43)</a>:</h4>
<p><span class="user-mention" data-user-id="216206">@lcnr</span> thanks for linking the internals post, I missed it previously</p>



<a name="203950512"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203950512" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Connor Horman <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203950512">(Jul 15 2020 at 12:50)</a>:</h4>
<p>The requirements for references in C++ are:</p>
<ul>
<li>
<p>Must be a reference to an object with <em>static storage duration</em> and that has linkage. Note that lifetime extended temporary objects, and string literals do not have linkage<br>
Pointers are similar, though the requirements are encoded in the definition of <em>pointer constant expression</em>:</p>
</li>
<li>
<p>Must be a null pointer, or</p>
</li>
<li>Must be a pointer to an object with <em>static storage duration</em> that has linkage, or</li>
<li>Must be a pointer one-passed-the-end of such an object, or</li>
<li>Must be a pointer to a function</li>
</ul>
<p>At least in C++, references are by-identity. Even different objects comparing equal would be considered to be different for instantiation purposes.</p>



<a name="203951383"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203951383" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203951383">(Jul 15 2020 at 12:58)</a>:</h4>
<p><span class="user-mention" data-user-id="257758">@Connor Horman</span> heh that's way more complicated than what we're doing/want to do in Rust, which is:</p>
<ul>
<li>raw pointers are disallowed (or largely behave like <code>usize</code>, allowing only integer addresses)</li>
<li>references are treated like newtypes (around the value they point to), just like <code>==</code> behaves on them</li>
</ul>



<a name="203951480"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203951480" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203951480">(Jul 15 2020 at 12:59)</a>:</h4>
<p>arguably C++ has a harder time doing the simpler/better thing for CTFE type stuff, due to everything else in the language</p>



<a name="203951702"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203951702" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203951702">(Jul 15 2020 at 13:00)</a>:</h4>
<p>although <code>constexpr</code> seems to be approaching what miri can do (and we haven't stabilized a good chunk of that yet, so you could say Rust is behind language-wise even when ahead technology-wise)</p>



<a name="203952964"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203952964" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Connor Horman <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203952964">(Jul 15 2020 at 13:11)</a>:</h4>
<p>Well, C++ does have the blessing (and curse) of being stuck behind a well-specified standard that is voted on by national bodies. It has the advantage that there is more than one correct, or incorrect (depending on how you look at it), implementation, but they also add stuff to the language at the pace of a snail.</p>



<a name="203984232"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203984232" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203984232">(Jul 15 2020 at 17:12)</a>:</h4>
<p><span class="user-mention silent" data-user-id="216206">lcnr</span> <a href="#narrow/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics/near/203941697">said</a>:</p>
<blockquote>
<p>everybody write <code>slice.array_chunks().map(|[a, b]| a + b)</code></p>
</blockquote>
<p><a href="https://github.com/rust-lang/rust/issues/74373">#74373</a> <span aria-label="tada" class="emoji emoji-1f389" role="img" title="tada">:tada:</span></p>



<a name="203990994"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203990994" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pachi <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203990994">(Jul 15 2020 at 18:05)</a>:</h4>
<p><span class="user-mention" data-user-id="216206">@lcnr</span> that's great! One thing that is not evident to me, as a plain user, and by reading the lorem example in the docs, is why, without giving an explicit N=2 const parameter, the array_chunks iterator you get returns chunks of two elements.</p>



<a name="203991199"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203991199" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203991199">(Jul 15 2020 at 18:06)</a>:</h4>
<div class="codehilite"><pre><span></span><code><span class="kd">let</span><span class="w"> </span><span class="n">v2</span>: <span class="kp">&amp;</span><span class="p">[</span><span class="kt">i32</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="o">&amp;</span><span class="p">[</span><span class="mi">0</span><span class="p">,</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="mi">2</span><span class="p">,</span><span class="w"> </span><span class="mi">3</span><span class="p">,</span><span class="w"> </span><span class="mi">4</span><span class="p">,</span><span class="w"> </span><span class="mi">5</span><span class="p">,</span><span class="w"> </span><span class="mi">6</span><span class="p">];</span><span class="w"></span>
<span class="kd">let</span><span class="w"> </span><span class="n">total</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">v2</span><span class="p">.</span><span class="n">array_chunks</span><span class="p">().</span><span class="n">map</span><span class="p">(</span><span class="o">|&amp;</span><span class="p">[</span><span class="n">a</span><span class="p">,</span><span class="w"> </span><span class="n">b</span><span class="p">]</span><span class="o">|</span><span class="w"> </span><span class="n">a</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="n">b</span><span class="p">).</span><span class="n">sum</span>::<span class="o">&lt;</span><span class="kt">i32</span><span class="o">&gt;</span><span class="p">();</span><span class="w"></span>
</code></pre></div>


<p>because of type inference. The closure <code>|&amp;[a, b]| a * b</code> has an irrefutable binding requiring an array with 2 elements</p>



<a name="203991270"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203991270" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203991270">(Jul 15 2020 at 18:07)</a>:</h4>
<p>Which is used to infer the value of <code>N</code> in <code>fn array_chunks</code></p>



<a name="203991341"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203991341" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pachi <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203991341">(Jul 15 2020 at 18:07)</a>:</h4>
<p>I meant the other example in the docstring:<br>
let slice = ['l', 'o', 'r', 'e', 'm'];<br>
let mut iter = slice.array_chunks();<br>
assert_eq!(iter.next().unwrap(), &amp;['l', 'o']);<br>
assert_eq!(iter.next().unwrap(), &amp;['r', 'e']);<br>
assert!(iter.next().is_none());<br>
assert_eq!(iter.remainder(), &amp;['m']);</p>



<a name="203991445"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203991445" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203991445">(Jul 15 2020 at 18:08)</a>:</h4>
<p>it's similar, the requirements "backflow" from the assert_eq into the iter</p>



<a name="203991486"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203991486" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pachi <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203991486">(Jul 15 2020 at 18:08)</a>:</h4>
<p>Oh! I see! Wow, I wouldn't have imagined that!</p>



<a name="203991491"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203991491" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203991491">(Jul 15 2020 at 18:08)</a>:</h4>
<p>Here we compare the result if <code>iter.next().unwrap()</code> with <code>&amp;['l', 'o']</code>. <code>[T; 2]</code> only implements partial equality with <code>[T; 2]</code> itself, which is then used to go backwards to <code>array_chunks</code>.</p>



<a name="203991606"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203991606" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pachi <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203991606">(Jul 15 2020 at 18:09)</a>:</h4>
<p>Yes, I can see how type inference does it, but I wouldn't expect it to be so smart...</p>



<a name="203991665"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203991665" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pachi <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203991665">(Jul 15 2020 at 18:09)</a>:</h4>
<p>well, at least I put assert out of its domain</p>



<a name="203991792"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203991792" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203991792">(Jul 15 2020 at 18:10)</a>:</h4>
<p>assert is just a normal expression when you get down to it</p>



<a name="203991841"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203991841" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203991841">(Jul 15 2020 at 18:11)</a>:</h4>
<p>if !(assertion) { panic!() }</p>



<a name="203993304"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/203993304" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pachi <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#203993304">(Jul 15 2020 at 18:22)</a>:</h4>
<p>Indeed, it's just me that these cases, like those using asserts to "remind" the optimizer some precondition that may not be clear at the point of use look like magic, but yeah. Thanks for the explanations!</p>



<a name="204000528"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/204000528" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#204000528">(Jul 15 2020 at 19:20)</a>:</h4>
<blockquote>
<p>Too bad that this is just a strictly better version of the existing chunks_exact</p>
</blockquote>
<p>Also me years ago when chunks_exact was introduced.</p>



<a name="204009620"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/204009620" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cuviper <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#204009620">(Jul 15 2020 at 20:36)</a>:</h4>
<p><span class="user-mention" data-user-id="216206">@lcnr</span> rayon can do it too! <a href="https://github.com/rayon-rs/rayon/compare/master...cuviper:array_chunks">https://github.com/rayon-rs/rayon/compare/master...cuviper:array_chunks</a></p>



<a name="204010037"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/204010037" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#204010037">(Jul 15 2020 at 20:40)</a>:</h4>
<p>Nice <span aria-label="thumbs up" class="emoji emoji-1f44d" role="img" title="thumbs up">:thumbs_up:</span> I am really happy with how well <a href="https://github.com/rust-lang/rust/issues/74113">#74113</a> seems to work. Did you encounter any problems while implementing this?</p>



<a name="204011403"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/204011403" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cuviper <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#204011403">(Jul 15 2020 at 20:52)</a>:</h4>
<p>I had weird type inference errors at first, using the current nightly, but those went away after <code>rustup-toolchain-install-master</code><br>
(nightly <a href="https://github.com/rust-lang/rust/commit/23744c84d9c0f8e4e870edb983f1ad6d33449c34">23744c84d9c0f8e4e870edb983f1ad6d33449c34</a> vs. master <a href="https://github.com/rust-lang/rust/commit/7e11379f3b4c376fbb9a6c4d44f3286ccc28d149">7e11379f3b4c376fbb9a6c4d44f3286ccc28d149</a>)</p>



<a name="204011420"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/204011420" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cuviper <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#204011420">(Jul 15 2020 at 20:52)</a>:</h4>
<p>which is explained by <a href="https://github.com/rust-lang/rust/issues/74113">#74113</a></p>



<a name="204011463"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/204011463" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#204011463">(Jul 15 2020 at 20:53)</a>:</h4>
<p>yeah, that PR isn't on nightly yet</p>



<a name="204011475"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/204011475" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cuviper <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#204011475">(Jul 15 2020 at 20:53)</a>:</h4>
<p><em>soon</em></p>



<a name="204021975"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/204021975" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> varkor <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#204021975">(Jul 15 2020 at 22:41)</a>:</h4>
<p>Sorry, I need to catch up on all of this discussion, but I think I'm in agreement with the conclusion from what I can see.</p>



<a name="204062016"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/204062016" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#204062016">(Jul 16 2020 at 09:25)</a>:</h4>
<p>I wonder if Miri will explode when those tests land^^</p>



<a name="204062032"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/204062032" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#204062032">(Jul 16 2020 at 09:25)</a>:</h4>
<p>that sometimes happened with new const generic stuff in the past</p>



<a name="204081671"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/204081671" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> boats <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#204081671">(Jul 16 2020 at 13:18)</a>:</h4>
<p>wrote a blog post to promote this vision: <a href="https://without.boats/blog/shipping-const-generics/">https://without.boats/blog/shipping-const-generics/</a></p>



<a name="204081718"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/204081718" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> boats <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#204081718">(Jul 16 2020 at 13:19)</a>:</h4>
<p>how does the compiler team track proposals like this (to create a new feature gate) nowadays?</p>



<a name="204081770"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/204081770" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#204081770">(Jul 16 2020 at 13:19)</a>:</h4>
<p>MCPs probably</p>



<a name="204081862"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/204081862" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> boats <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#204081862">(Jul 16 2020 at 13:20)</a>:</h4>
<p>so same as lang, cool</p>



<a name="204081870"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/204081870" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#204081870">(Jul 16 2020 at 13:20)</a>:</h4>
<p>yeah</p>



<a name="204081984"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/204081984" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#204081984">(Jul 16 2020 at 13:21)</a>:</h4>
<p><code>impl&lt;T: Debug, const N: usize&gt; Debug for [T; N&gt;</code><br>
Replace <code>&gt;</code> with <code>]</code></p>



<a name="204090324"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/204090324" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#204090324">(Jul 16 2020 at 14:24)</a>:</h4>
<p><span class="user-mention" data-user-id="256759">@boats</span> hmm, idk how important this is, but instead of <code>[T; {N + M}]</code> I'd give both <code>[T; N + M]</code> and <code>ArrayVec&lt;T, {N + M}&gt;</code> as examples (the braces being necessary only for the latter)</p>



<a name="204090367"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/204090367" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> boats <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#204090367">(Jul 16 2020 at 14:25)</a>:</h4>
<p><span class="user-mention" data-user-id="119009">@eddyb</span> I forgot the braces aren't necessary for arrays</p>



<a name="204090553"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/204090553" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> boats <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#204090553">(Jul 16 2020 at 14:26)</a>:</h4>
<p>but only in those examples did I forget <span aria-label="lol" class="emoji emoji-1f606" role="img" title="lol">:lol:</span></p>



<a name="204090606"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/204090606" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#204090606">(Jul 16 2020 at 14:26)</a>:</h4>
<p>you did use braceless expressions lower down. I've sometimes seen people assume <code>{N}</code> is the name of a <code>const N</code> parameter, or something of the sort, not sure exactly what led to stuff like that</p>



<a name="204090632"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/204090632" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#204090632">(Jul 16 2020 at 14:26)</a>:</h4>
<p>for a while <code>Foo&lt;T, N&gt;</code> didn't work so that's probably part of it I think</p>



<a name="204090725"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/204090725" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#204090725">(Jul 16 2020 at 14:27)</a>:</h4>
<p>anyway not on topic but loving the night mode theme :D</p>



<a name="204096226"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/204096226" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> boats <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#204096226">(Jul 16 2020 at 15:04)</a>:</h4>
<p><a href="https://github.com/rust-lang/compiler-team/issues/332">https://github.com/rust-lang/compiler-team/issues/332</a></p>



<a name="204098298"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/204098298" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#204098298">(Jul 16 2020 at 15:19)</a>:</h4>
<p>any chance we could merge this thread with the MCP thread for that? cc <span class="user-mention" data-user-id="116122">@simulacrum</span></p>



<a name="204098328"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/204098328" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#204098328">(Jul 16 2020 at 15:19)</a>:</h4>
<p>no idea</p>



<a name="204098360"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/204098360" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#204098360">(Jul 16 2020 at 15:19)</a>:</h4>
<p>we'd lose the thread here</p>



<a name="204098368"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/204098368" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#204098368">(Jul 16 2020 at 15:19)</a>:</h4>
<p>I mean worst case you move it to that stream with the current name and then if you rename the topic they get merged</p>



<a name="204098500"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/204098500" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#204098500">(Jul 16 2020 at 15:20)</a>:</h4>
<p>yeah -- I'm just not sure we <em>want</em> to unify them</p>



<a name="204098532"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/204098532" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#204098532">(Jul 16 2020 at 15:20)</a>:</h4>
<p>alright</p>



<a name="204196601"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/204196601" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#204196601">(Jul 17 2020 at 11:49)</a>:</h4>
<p>I hope stabilizing this is blocked on having a valtree representation and two kinds of CTFE queries (one to get "raw bytes" that works for everything, and one to get the valtree that just works for types with "sufficiently well-behaved equality")? I'm worried that the current state in rustc might have too many unexpected surprises still lurking somewhere.</p>



<a name="204196692"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/204196692" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#204196692">(Jul 17 2020 at 11:50)</a>:</h4>
<p>We only want stabilize types represented as <code>ConstValue::Scalar</code>, which shouldn't have to deal with these problems, should it?</p>



<a name="204196722"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/204196722" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#204196722">(Jul 17 2020 at 11:51)</a>:</h4>
<p>or more accurately integers, bool and char</p>



<a name="204196885"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/204196885" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#204196885">(Jul 17 2020 at 11:53)</a>:</h4>
<p>hm I guess... but the entire logic that decides which <code>ConstValue</code> representation to use is a mess, and valtrees would get rid of it</p>



<a name="204204219"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/204204219" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#204204219">(Jul 17 2020 at 13:16)</a>:</h4>
<p>/me whispers something about pointers being scalars</p>



<a name="204211075"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/204211075" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#204211075">(Jul 17 2020 at 14:18)</a>:</h4>
<p><a href="https://www.ralfj.de/blog/2018/07/24/pointers-and-bytes.html">heretic!</a></p>



<a name="204222442"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/204222442" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#204222442">(Jul 17 2020 at 15:46)</a>:</h4>
<p><span class="user-mention" data-user-id="120791">@RalfJ</span> Is there a reference I could read about "valtree"? I haven't heard of it before.</p>



<a name="204222550"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/204222550" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#204222550">(Jul 17 2020 at 15:47)</a>:</h4>
<p>I think <a href="https://github.com/rust-lang/compiler-team/issues/323">https://github.com/rust-lang/compiler-team/issues/323</a> is a good summary</p>



<a name="204223080"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/204223080" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#204223080">(Jul 17 2020 at 15:51)</a>:</h4>
<p><span class="user-mention" data-user-id="124288">@oli</span> I renamed the MCP to "value tree"; I hope that's okay</p>



<a name="204223092"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/204223092" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#204223092">(Jul 17 2020 at 15:51)</a>:</h4>
<p><a href="https://github.com/rust-lang/rust/issues/70889">https://github.com/rust-lang/rust/issues/70889</a> shows some of the issues with our current approach (the user-visible ones -- the other issue is that it's rather messy internally)</p>



<a name="204223094"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/204223094" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#204223094">(Jul 17 2020 at 15:51)</a>:</h4>
<p><span aria-label="+1" class="emoji emoji-1f44d" role="img" title="+1">:+1:</span></p>



<a name="204229667"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/204229667" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#204229667">(Jul 17 2020 at 16:43)</a>:</h4>
<p>hm I now feel like "scalar tree" would be even better -- it's a tree of scalars at the leafs...</p>



<a name="204229704"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/204229704" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#204229704">(Jul 17 2020 at 16:43)</a>:</h4>
<p>but I guess if <span class="user-mention" data-user-id="119009">@eddyb</span> didnt like "integer tree" he wont like "scalar tree" either. whatever.^^</p>



<a name="204229764"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/204229764" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#204229764">(Jul 17 2020 at 16:44)</a>:</h4>
<p>("value tree" sounds like you could e.g. just put "the value of a union" into it, which you cannot; that's one of the key points, really)</p>



<a name="204232489"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/204232489" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#204232489">(Jul 17 2020 at 17:09)</a>:</h4>
<p>IMO the ADT "nodes" are more interesting than the leaves</p>



<a name="204232565"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/204232565" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#204232565">(Jul 17 2020 at 17:10)</a>:</h4>
<p>which are just units because natural numbers are ADTs,</p>



<a name="204232598"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/204232598" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#204232598">(Jul 17 2020 at 17:10)</a>:</h4>
<p>(I mean ADT in the product/sum sense that an union isn't)</p>



<a name="204232656"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/204232656" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#204232656">(Jul 17 2020 at 17:10)</a>:</h4>
<p><span class="user-mention silent" data-user-id="120791">RalfJ</span> <a href="#narrow/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics/near/204211075">said</a>:</p>
<blockquote>
<p><a href="https://www.ralfj.de/blog/2018/07/24/pointers-and-bytes.html">heretic!</a></p>
</blockquote>
<p>it's literally "Scalar" in miri</p>



<a name="204232675"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/204232675" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#204232675">(Jul 17 2020 at 17:11)</a>:</h4>
<p>I'm not making stuff up (... am I?)</p>



<a name="204232870"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/204232870" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> boats <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#204232870">(Jul 17 2020 at 17:13)</a>:</h4>
<p><span class="user-mention" data-user-id="120791">@RalfJ</span> the goal of limiting the types of consts is to not block on that change</p>



<a name="204318632"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/204318632" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#204318632">(Jul 18 2020 at 21:28)</a>:</h4>
<p>just realized we also should forbid default types for structs with const generic parameters</p>



<a name="204318641"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/204318641" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#204318641">(Jul 18 2020 at 21:29)</a>:</h4>
<p>i.e. forbid <code>struct Foo&lt;T = u32, const N: usize&gt;</code></p>



<a name="204318649"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/204318649" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#204318649">(Jul 18 2020 at 21:29)</a>:</h4>
<p>ref <a href="https://github.com/rust-lang/rust/issues/70471">#70471</a> (which I don't really want to stabilize yet)</p>



<a name="204324177"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/204324177" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#204324177">(Jul 19 2020 at 00:24)</a>:</h4>
<p>isn't that disallowed for the same reason we don't allow <code>&lt;T = u32, U&gt;</code>?</p>



<a name="204337600"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/204337600" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#204337600">(Jul 19 2020 at 07:40)</a>:</h4>
<p>not rn</p>



<a name="204337601"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/204337601" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#204337601">(Jul 19 2020 at 07:40)</a>:</h4>
<p>but we should</p>



<a name="204421038"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/204421038" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> boats <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#204421038">(Jul 20 2020 at 13:21)</a>:</h4>
<p>we currently don</p>



<a name="204421123"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/204421123" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> boats <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#204421123">(Jul 20 2020 at 13:22)</a>:</h4>
<p>*don't allow free ordering among types and consts, right? const params must come after right now?</p>



<a name="204421502"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/204421502" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#204421502">(Jul 20 2020 at 13:26)</a>:</h4>
<p>yes</p>



<a name="204425448"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/204425448" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#204425448">(Jul 20 2020 at 14:01)</a>:</h4>
<p>I'm a bit worried at how artificial that is and if we'll end up with some weird assumptions that rely on that order</p>



<a name="204428127"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/204428127" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#204428127">(Jul 20 2020 at 14:22)</a>:</h4>
<p>we already have some assumptions here which cause ICE on unordered parameters (we currently fix this by sorting them)</p>



<a name="204428198"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/204428198" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#204428198">(Jul 20 2020 at 14:23)</a>:</h4>
<p>I also think its probably a good idea to allow consts and types in an arbitrary order, which would also make me more comfortable with allowing type defaults in the future</p>



<a name="204653023"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/204653023" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> varkor <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#204653023">(Jul 22 2020 at 11:13)</a>:</h4>
<p>I think we should allow them in any order, but there were a couple of non-obvious issues with removing that assumption last time I checked (albeit quite a long time ago).</p>



<a name="204670135"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/204670135" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> boats <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#204670135">(Jul 22 2020 at 14:08)</a>:</h4>
<p>i think in the longer term allowing them in any order is probably a good idea. for now i'd just want to make sure that this wont be a breaking change</p>



<a name="204717880"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/204717880" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#204717880">(Jul 22 2020 at 20:22)</a>:</h4>
<p>Do we want to add the usage restriction of either <code>N</code> or a concrete value also to repeat expressions and enum discriminants?</p>



<a name="204717946"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/204717946" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#204717946">(Jul 22 2020 at 20:22)</a>:</h4>
<p>So rn <code>let _ = [0; std::mem::size_of::&lt;*mut T&gt;()]</code> works on stable.</p>



<a name="204718395"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/204718395" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#204718395">(Jul 22 2020 at 20:26)</a>:</h4>
<p>If we implement this check in name resolution, we either forbid this or don't add this restriction in these cases, which is imo quite inconsistent</p>



<a name="204718586"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/204718586" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#204718586">(Jul 22 2020 at 20:28)</a>:</h4>
<p>we should forbid this anyways IMO, see <a href="#narrow/stream/146212-t-compiler.2Fconst-eval/topic/.60ConstEvaluatable.60.20generic.20functions/near/204125452">https://rust-lang.zulipchat.com/#narrow/stream/146212-t-compiler.2Fconst-eval/topic/.60ConstEvaluatable.60.20generic.20functions/near/204125452</a> for the relevant discussion and <a href="https://github.com/rust-lang/rust/issues/74595">#74595</a> for a short summary and crater run</p>



<a name="204725100"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/204725100" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> boats <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#204725100">(Jul 22 2020 at 21:28)</a>:</h4>
<p>im a bit concerned about const fns leaking facts about their bodies like this (and the example with <code>if</code>)</p>



<a name="204776782"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/204776782" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#204776782">(Jul 23 2020 at 09:32)</a>:</h4>
<p>me too, which is why I opened <a href="https://github.com/rust-lang/rust/issues/74595">#74595</a> <span aria-label="laughing" class="emoji emoji-1f606" role="img" title="laughing">:laughing:</span></p>



<a name="204787480"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/204787480" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#204787480">(Jul 23 2020 at 12:04)</a>:</h4>
<p><span class="user-mention silent" data-user-id="256759">boats</span> <a href="#narrow/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics/near/204232870">said</a>:</p>
<blockquote>
<p><span class="user-mention silent" data-user-id="120791">RalfJ</span> the goal of limiting the types of consts is to not block on that change</p>
</blockquote>
<p>fair. looks like we'll have to be careful then.<br>
(not sure where on <span class="user-mention" data-user-id="124288">@oli</span> 's timeline the valtree change is.)</p>



<a name="205246655"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/205246655" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#205246655">(Jul 28 2020 at 15:00)</a>:</h4>
<p>Opened <a href="https://github.com/rust-lang/rust/issues/74877">#74877</a> which implements the feature gate and all mentioned restrictions. There are still some annoying problems here, but it's fairly nice to use const generics without having to deal with <code>incomplete_features</code>warning  <span aria-label="sparkles" class="emoji emoji-2728" role="img" title="sparkles">:sparkles:</span></p>



<a name="205259682"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/205259682" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Léo Lanteri Thauvin <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#205259682">(Jul 28 2020 at 16:38)</a>:</h4>
<p><span aria-label="tada" class="emoji emoji-1f389" role="img" title="tada">:tada:</span></p>



<a name="205343966"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/205343966" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> boats <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#205343966">(Jul 29 2020 at 11:27)</a>:</h4>
<p><span class="user-mention" data-user-id="216206">@lcnr</span> I didn't understand the feature to include any change to associated consts</p>



<a name="205344008"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/205344008" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> boats <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#205344008">(Jul 29 2020 at 11:27)</a>:</h4>
<p>can you ellaborate on why your PR impacts that?</p>



<a name="205344055"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/205344055" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#205344055">(Jul 29 2020 at 11:28)</a>:</h4>
<p>There is a bit more discussion in <a href="#narrow/stream/146212-t-compiler.2Fconst-eval/topic/associated.20consts.20const.20wf">https://rust-lang.zulipchat.com/#narrow/stream/146212-t-compiler.2Fconst-eval/topic/associated.20consts.20const.20wf</a></p>



<a name="205344076"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/205344076" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#205344076">(Jul 29 2020 at 11:28)</a>:</h4>
<p>and I will probably revert that change because it's already to late here</p>



<a name="205344092"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/205344092" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#205344092">(Jul 29 2020 at 11:28)</a>:</h4>
<p>(i.e. we can't really do what I wanted without breaking stable code)</p>



<a name="205344383"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/205344383" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> boats <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#205344383">(Jul 29 2020 at 11:32)</a>:</h4>
<p>thanks, i think it should be separated, but we likely want to treat it as a bug and start a future deprecation cycle</p>



<a name="205344404"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/205344404" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#205344404">(Jul 29 2020 at 11:32)</a>:</h4>
<p>I am currently trying to write a lang team MCP with both a summary of what const wf is, why we would like to statically enforce this, and how we will do so.</p>



<a name="205344479"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/205344479" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#205344479">(Jul 29 2020 at 11:33)</a>:</h4>
<p><span class="user-mention silent" data-user-id="256759">boats</span> <a href="#narrow/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics/near/205344383">said</a>:</p>
<blockquote>
<p>thanks, i think it should be separated, but we likely want to treat it as a bug and start a future deprecation cycle</p>
</blockquote>
<p>So you want to forbid</p>
<div class="codehilite"><pre><span></span><code><span class="k">impl</span><span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="w"> </span><span class="n">Foo</span><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="n">T</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">const</span><span class="w"> </span><span class="n">ASSOC</span>: <span class="kt">usize</span> <span class="o">=</span><span class="w"> </span><span class="mi">64</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="n">std</span>::<span class="n">mem</span>::<span class="n">size_of</span>::<span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="p">();</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="205344669"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/205344669" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#205344669">(Jul 29 2020 at 11:36)</a>:</h4>
<p>The relevant question for <code>T-lang</code> is:</p>
<blockquote>
<p>What I am now still unsure of is if we want to restrict associated consts to just <code>N</code> and <code>{ N }</code> for min_const_generics</p>
</blockquote>



<a name="205344678"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/205344678" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#205344678">(Jul 29 2020 at 11:36)</a>:</h4>
<p>So should we allow more complex expressions using const params in associated consts?</p>



<a name="205344745"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/205344745" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#205344745">(Jul 29 2020 at 11:37)</a>:</h4>
<p>My idea would be that we start warning in the future if we have associated consts without a corresponding const wf bound</p>



<a name="205344804"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/205344804" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#205344804">(Jul 29 2020 at 11:38)</a>:</h4>
<p>but for that I would first want to actually implement const wf bounds, so these warnings are actionable</p>



<a name="205344921"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/205344921" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#205344921">(Jul 29 2020 at 11:40)</a>:</h4>
<p>So it might make sense to restrict any associated consts which use const params to just the param itself until const wf bounds are on stable, where we then both allow more complex usage of const params and warn if the trait impl is missing a const wf bound</p>



<a name="205346683"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/205346683" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> boats <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#205346683">(Jul 29 2020 at 11:59)</a>:</h4>
<p>I would expect it to allow anything thats allowed in other consts that are not input to the type system</p>



<a name="205346812"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/205346812" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#205346812">(Jul 29 2020 at 12:00)</a>:</h4>
<p>associated consts are the only consts rn which are not input to the type system and can use generic params afaik</p>



<a name="205356507"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/205356507" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> boats <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#205356507">(Jul 29 2020 at 13:34)</a>:</h4>
<p>right, other consts can't use params ofc</p>



<a name="205356530"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/205356530" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> boats <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#205356530">(Jul 29 2020 at 13:34)</a>:</h4>
<p>yea we need to think through it more</p>



<a name="205523733"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/205523733" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#205523733">(Jul 30 2020 at 19:45)</a>:</h4>
<p><span class="user-mention" data-user-id="326189">@jknodt</span> opened PR <a href="https://github.com/rust-lang/rust/issues/74953">#74953</a> which removes the ordering restriction on types and const parameters, allowing the following</p>
<div class="codehilite"><pre><span></span><code><span class="k">struct</span> <span class="nc">Foo</span><span class="o">&lt;</span><span class="k">const</span><span class="w"> </span><span class="n">N</span>: <span class="kt">usize</span><span class="p">,</span><span class="w"> </span><span class="n">T</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="kt">u32</span><span class="o">&gt;</span><span class="p">([</span><span class="n">T</span><span class="p">;</span><span class="w"> </span><span class="n">N</span><span class="p">]);</span><span class="w"></span>
</code></pre></div>


<p>Do we want to allow this as part of the MCP? Doing so would not be an implementation challenge so it's mostly up for the lang team to decide</p>



<a name="205523741"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/205523741" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#205523741">(Jul 30 2020 at 19:45)</a>:</h4>
<p>see <a href="https://github.com/rust-lang/rust/pull/74953#issuecomment-666640203">https://github.com/rust-lang/rust/pull/74953#issuecomment-666640203</a></p>



<a name="205563561"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/205563561" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#205563561">(Jul 31 2020 at 07:04)</a>:</h4>
<p>Would the min_const_generics allow the generic int value to be cast to other int types?</p>
<p>Eg, const generic on <code>u16</code> and then use the value in code with <code>N as usize</code></p>



<a name="205585250"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/205585250" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#205585250">(Jul 31 2020 at 12:35)</a>:</h4>
<p>no, it allows exactly <code>N</code> and <code>{ N }</code>.</p>



<a name="205586071"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/205586071" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#205586071">(Jul 31 2020 at 12:46)</a>:</h4>
<p>afaik getting these casts right without hacks pretty much requires something like <a href="#narrow/stream/146212-t-compiler.2Fconst-eval/topic/const.20wf.20bounds.20implementation/near/205476289">https://rust-lang.zulipchat.com/#narrow/stream/146212-t-compiler.2Fconst-eval/topic/const.20wf.20bounds.20implementation/near/205476289</a>.</p>



<a name="205843745"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/205843745" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#205843745">(Aug 03 2020 at 20:30)</a>:</h4>
<p><span class="user-mention" data-user-id="224471">@Lokathor</span> by "in code", do you mean <code>N as usize</code> as a normal value in the body, as opposed to in a generic argument?</p>



<a name="205844051"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/205844051" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#205844051">(Aug 03 2020 at 20:32)</a>:</h4>
<div class="codehilite"><pre><span></span><code><span class="k">fn</span> <span class="nf">test</span><span class="o">&lt;</span><span class="k">const</span><span class="w"> </span><span class="n">N</span>: <span class="kt">u8</span><span class="o">&gt;</span><span class="p">()</span><span class="w"> </span>-&gt; <span class="p">[</span><span class="kt">u8</span><span class="p">;</span><span class="w"> </span><span class="n">N</span><span class="w"> </span><span class="k">as</span><span class="w"> </span><span class="kt">usize</span><span class="p">]</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="n">todo</span><span class="o">!</span><span class="p">()</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>


<p>is forbidden</p>
<div class="codehilite"><pre><span></span><code><span class="k">fn</span> <span class="nf">test</span><span class="o">&lt;</span><span class="k">const</span><span class="w"> </span><span class="n">N</span>: <span class="kt">u8</span><span class="o">&gt;</span><span class="p">()</span><span class="w"> </span>-&gt; -&gt; <span class="kt">usize</span> <span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="n">N</span><span class="w"> </span><span class="k">as</span><span class="w"> </span><span class="kt">usize</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>


<p>is allowed (you can use const params as you like inside of a function, as long as they don't feed back into the type system)</p>



<a name="205844235"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/205844235" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#205844235">(Aug 03 2020 at 20:34)</a>:</h4>
<p>yes i mean in a function body, not a type</p>



<a name="205844274"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/205844274" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#205844274">(Aug 03 2020 at 20:34)</a>:</h4>
<p>inside of the function body it's allowed, sry for misunderstanding you</p>



<a name="206016748"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/206016748" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> boats <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#206016748">(Aug 05 2020 at 12:39)</a>:</h4>
<p>Is anyone able to review <a href="https://github.com/rust-lang/rust/issues/74877">#74877</a>?</p>



<a name="206016860"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/206016860" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> boats <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#206016860">(Aug 05 2020 at 12:41)</a>:</h4>
<p><span class="user-mention" data-user-id="216206">@lcnr</span> as to <a href="https://github.com/rust-lang/rust/issues/74953">#74953</a>, I do not think it should be included in the MVP. I think there are concerns once you start allowing mixed ordering and default parameters about backwards compatibility hazards, so I think we should take more time to think through that functionality.</p>



<a name="206049231"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/206049231" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#206049231">(Aug 05 2020 at 17:04)</a>:</h4>
<p><span class="user-mention" data-user-id="124288">@oli</span> /general </p>
<p>I removed the restriction on associated consts, meaning that the following now compiles:</p>
<div class="codehilite"><pre><span></span><code><span class="cp">#![feature(min_const_generics)]</span><span class="w"></span>

<span class="k">trait</span><span class="w"> </span><span class="n">Foo</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">const</span><span class="w"> </span><span class="n">ASSOC</span>: <span class="kt">usize</span><span class="p">;</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="k">impl</span><span class="o">&lt;</span><span class="k">const</span><span class="w"> </span><span class="n">N</span>: <span class="kt">usize</span><span class="o">&gt;</span><span class="w"> </span><span class="n">Foo</span><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="p">[</span><span class="kt">u8</span><span class="p">;</span><span class="w"> </span><span class="n">N</span><span class="p">]</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">const</span><span class="w"> </span><span class="n">ASSOC</span>: <span class="kt">usize</span> <span class="o">=</span><span class="w"> </span><span class="mi">64</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="n">N</span><span class="p">;</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="206049490"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/206049490" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#206049490">(Aug 05 2020 at 17:06)</a>:</h4>
<p>While we probably want to warn here once this can be restricted using const wf bounds, we already allow things like <code>64 / std::mem::size_of::&lt;T&gt;()</code> here which have the same problem. For more details see  <a href="#narrow/stream/146212-t-compiler.2Fconst-eval/topic/associated.20consts.20const.20wf">https://rust-lang.zulipchat.com/#narrow/stream/146212-t-compiler.2Fconst-eval/topic/associated.20consts.20const.20wf</a></p>



<a name="206049639"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/stable%20subset%20of%20const%20generics/near/206049639" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/stable.20subset.20of.20const.20generics.html#206049639">(Aug 05 2020 at 17:07)</a>:</h4>
<p>Can we write a short internals post to get people to test this once it's on nightly?</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>